location PATHTOCHANGE { index index.php; alias ALIASTOCHANGE; error_page 500 502 503 504 /50x.html; location = PATHTOCHANGE/50x.html { root html; } location PATHTOCHANGE { if (!-e $request_filename){ rewrite ^(.*)$ PATHTOCHANGE/$2 last; } try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { # Choose either a socket or TCP/IP address fastcgi_pass unix:/var/run/php5-fpm.sock; # fastcgi_pass 127.0.0.1:9000; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $request_filename; } ## Begin - Security # deny all direct access for these folders location ~* /(.git|cache|bin|logs|backups)/.*$ { return 403; } # deny running scripts inside core system folders location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|php|pl|py|cgi|twig|sh|bat)$ { return 403; } # deny running scripts inside user folder location ~* /user/.*\.(txt|md|yaml|php|pl|py|cgi|twig|sh|bat)$ { return 403; } # deny access to specific files in the root folder location ~ /(LICENSE|composer.lock|composer.json|nginx.conf|web.config|htaccess.txt|\.htaccess) { return 403; } ## End - Security }