|
| 1 | +server { |
| 2 | + listen ${NGINX_PORT}; |
| 3 | + server_name localhost; |
| 4 | + |
| 5 | + root ${NGINX_WEB_ROOT}; |
| 6 | + |
| 7 | + client_max_body_size ${NGINX_MAX_BODY_SIZE}; |
| 8 | + |
| 9 | + # This also needs to be set in the single server tag and not only in http. |
| 10 | + set_real_ip_from 172.16.0.0/16; |
| 11 | + real_ip_recursive on; |
| 12 | + real_ip_header X-Forwarded-For; |
| 13 | + |
| 14 | + location / { |
| 15 | + # We are co-hosting with the legacy EventDB, so this app is hosted under '/v1' |
| 16 | + # This is configured for Symfony in 'framework.assets.base_path'. However |
| 17 | + # Symfony still installs assets in the root path so we need to rewrite the uri to remove '/v1'. |
| 18 | + rewrite ^/v1/bundles/(.*) /bundles/$1 break; |
| 19 | + |
| 20 | + # try to serve file directly, fallback to index.php |
| 21 | + try_files $uri /app_dev.php$is_args$args; |
| 22 | + } |
| 23 | + |
| 24 | + # Protect files and directories from prying eyes. |
| 25 | + location ~* \.(engine|inc|install|make|module|profile|po|sh|.*sql|.tar|.gz|.bz2|theme|twig|tpl(\.php)?|xtmpl|yml)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\.(?!well-known).*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock)|web\.config)$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig|\.save)$ { |
| 26 | + deny all; |
| 27 | + return 404; |
| 28 | + } |
| 29 | + |
| 30 | + # Development |
| 31 | + location ~ ^/(app_dev|config)\.php(/|$) { |
| 32 | + fastcgi_buffers 16 32k; |
| 33 | + fastcgi_buffer_size 64k; |
| 34 | + fastcgi_busy_buffers_size 64k; |
| 35 | + |
| 36 | + fastcgi_pass ${NGINX_FPM_SERVICE}; |
| 37 | + fastcgi_split_path_info ^(.+\.php)(/.*)$; |
| 38 | + include fastcgi_params; |
| 39 | + |
| 40 | + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; |
| 41 | + fastcgi_param DOCUMENT_ROOT $realpath_root; |
| 42 | + } |
| 43 | + |
| 44 | + # Production |
| 45 | + location ~ ^/app\.php(/|$) { |
| 46 | + fastcgi_pass ${NGINX_FPM_SERVICE}; |
| 47 | + fastcgi_split_path_info ^(.+\.php)(/.*)$; |
| 48 | + include fastcgi_params; |
| 49 | + |
| 50 | + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; |
| 51 | + fastcgi_param DOCUMENT_ROOT $realpath_root; |
| 52 | + |
| 53 | + internal; |
| 54 | + } |
| 55 | + |
| 56 | + |
| 57 | + location ~ \.php$ { |
| 58 | + return 404; |
| 59 | + } |
| 60 | + |
| 61 | + # Send log message to files symlinked to stdout/stderr. |
| 62 | + error_log /dev/stderr; |
| 63 | + access_log /dev/stdout main; |
| 64 | +} |
0 commit comments