nginx Config Check

trichome

Member
I've set up my first LEMP server and have xF running with friendly URLs. Everything seems to be working fine but I'm hoping a seasoned vet can take a look over this virtual host config, especially the commented lines.

First comment is self explanatory.

For the second comment, that line is part of the xF recommended setup but doesn't work along with the try_files directive above it, which I understand is needed for security. Friendly URLs seem to work fine with it commented out though.

Thanks!

Code:
server {
    server_name www.example.com example.com;
    access_log /srv/www/example.com/logs/access.log;
    error_log /srv/www/example.com/logs/error.log;
    root /home/user/www/example.com/public_html;
 
    location / {
        index index.html index.htm index.php;
    }
    location /xen/ {
        try_files $uri $uri/ /xen/index.php?$uri&$args;
        #nginx pitfalls says multiple index directives is bad, but friendly URLs don't work without this
        index index.php index.html;
    }
    location /xen/internal_data/ {
        internal;
    }
    location /xen/library/ {
        internal;
    }
 
    location ~ \.php$ {
        try_files $uri =404;
        #try_files $uri /xen/index.php;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}
 
This is what I have:

Code:
server {
  listen *:80;
  server_name www.domain.com;
  rewrite ^/(.*) http://domain.com/$1 permanent;
}
##################
 
 
server {
      listen *:80;
      server_name  domain.com;
 
    root /home/username/www;
 
        location / {
            index index.php;
            try_files $uri $uri/ /index.php?$uri&$args;
         
        }
 
        #nobody should be in here
        location /(data|internal_data|library)/ {
        allow 127.0.0.1;
        deny all;
        }
 
location ~ \.php$ {
      try_files $uri =404;
      fastcgi_pass  unix:/var/run/php-fpm/php-fpm.sock;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
      include        fastcgi_params;
}
 
## Disable viewing .htaccess & .htpassword
        location ~ /\.ht {
        deny all;
        }
 
}
 
Top Bottom