Mastering Nginx

(Ron) #1

Troubleshooting Techniques


[ 206 ]

server {

server_name http://www.example.com;

root /var/www/html;

location / {

}

}

Not using the server context to best effect


Another place where copied configuration snippets often lead to incorrect


configurations is the area of the server context. The server context describes
the whole virtual server (everything that should be addressed under a particular


server_name). It is underutilized in these copied configuration snippets.


Often, we will see root and index specified per location:


server {

server_name http://www.example.com;

location / {

root /var/www/html;

index index.php index.html index.htm;

}

location /ftp{

root /var/www/html;

index index.php index.html index.htm;

}

}
Free download pdf