Posts

Showing posts from September, 2015

Nginx vhost redirects with and without location.

Nginx is a very good Web servers which is fast and highly customizable. Following are the few redirects used in daily work.

A simple vhost with HTTP and HTTPS configuration.
server { listen 80; server_name testsite.domain.com; root /data/html/; index index.html index.htm; access_log /var/log/nginx/testsite.domain.com_access.log; error_log /var/log/nginx/testsite.domain.com_error.log; include /etc/nginx/denyhost.conf; } server { listen 443 ssl; server_name testsite.domain.com; root /data/html/; index index.html index.htm; access_log /var/log/nginx/testsite.domain.com_access.log; error_log /var/log/nginx/testsite.domain.com_error.log; include /etc/nginx/denyhost.conf; } listen : Its for port on which you want web server to listen, 80 for HTTP and 443 for HTTPS.
server_name : For domain name to be hosted.
root : Its the location of sites document directory.
index : For pages which need to be rendered first.
access_log & error_log : for sites logs.
includ…