Avice for my vhost configuration

Mik J mikydevel at yahoo.fr
Mon Aug 5 21:44:25 UTC 2013


I plan to configure my nginx server with a couple of vhosts.
For each of them I want:
- to use php
- deny access begining by a dot
- not logging access to favicon

So my configuration would look like that
server {

        location ~ \.php$ {
            root           /var/www/htdocs/sites/expertinet;
            fastcgi_pass   unix:/tmp/php.sock;
#            fastcgi_pass;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME      $document_root$fastcgi_script_name;
            include        fastcgi_params;

        location ~ /\. {
            access_log off;
            log_not_found off;
            deny all;

        location = /favicon.ico {
            return 204;
            access_log off;
                log_not_found off;
                expires 30d;

This in each of my virtual host configuration. This is very redundant.
For example if I want to use tcp socket for fastcgi_pass, I need to edit every single vhost configuration.

What are you advices to avoid this ? What is the recommended practice ?
Someone adviced my to use include... Could you show me an example ?

Thank you
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20130805/6ea53dff/attachment-0001.html>

More information about the nginx mailing list