|
| 1 | +server { |
| 2 | + server_name domain.tld www.domain.tld; |
| 3 | + root /home/<username>/www/<sitename>/web; |
| 4 | + |
| 5 | + location / { |
| 6 | + # try to serve file directly, fallback to app.php |
| 7 | + try_files $uri /app.php$is_args$args; |
| 8 | + } |
| 9 | + # DEV |
| 10 | + # This rule should only be placed on your development environment |
| 11 | + # In production, don't include this and don't deploy app_dev.php or config.php |
| 12 | + location ~ ^/(app_dev|config)\.php(/|$) { |
| 13 | + fastcgi_pass localhost:9000; |
| 14 | + fastcgi_split_path_info ^(.+\.php)(/.*)$; |
| 15 | + include fastcgi_params; |
| 16 | + # When you are using symlinks to link the document root to the |
| 17 | + # current version of your application, you should pass the real |
| 18 | + # application path instead of the path to the symlink to PHP |
| 19 | + # FPM. |
| 20 | + # Otherwise, PHP's OPcache may not properly detect changes to |
| 21 | + # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 |
| 22 | + # for more information). |
| 23 | + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; |
| 24 | + fastcgi_param DOCUMENT_ROOT $realpath_root; |
| 25 | + } |
| 26 | + # PROD |
| 27 | + location ~ ^/app\.php(/|$) { |
| 28 | + fastcgi_pass localhost:9000; |
| 29 | + fastcgi_split_path_info ^(.+\.php)(/.*)$; |
| 30 | + include fastcgi_params; |
| 31 | + # When you are using symlinks to link the document root to the |
| 32 | + # current version of your application, you should pass the real |
| 33 | + # application path instead of the path to the symlink to PHP |
| 34 | + # FPM. |
| 35 | + # Otherwise, PHP's OPcache may not properly detect changes to |
| 36 | + # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 |
| 37 | + # for more information). |
| 38 | + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; |
| 39 | + fastcgi_param DOCUMENT_ROOT $realpath_root; |
| 40 | + # Prevents URIs that include the front controller. This will 404: |
| 41 | + # http://domain.tld/app.php/some-path |
| 42 | + # Remove the internal directive to allow URIs like this |
| 43 | + internal; |
| 44 | + } |
| 45 | + |
| 46 | + # return 404 for all other php files not matching the front controller |
| 47 | + # this prevents access to other php files you don't want to be accessible. |
| 48 | + location ~ \.php$ { |
| 49 | + return 404; |
| 50 | + } |
| 51 | + |
| 52 | + error_log /var/log/nginx/<sitename>_error.log; |
| 53 | + access_log /var/log/nginx/<sitename>_access.log; |
| 54 | +} |
0 commit comments