server { listen 80; server_name localhost; root /var/www/app; location favicon.ico { return 404; } location / { try_files $uri /main.php$is_args$args; } location ~ ^/main\.php(/|$) { client_max_body_size 50m; fastcgi_pass php:9000; fastcgi_buffers 32 16k; fastcgi_buffer_size 32k; fastcgi_split_path_info ^(.+\.php)(/.*)$; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT $realpath_root; internal; } # return 404 for all other php files not matching the front controller location ~ \.php$ { return 404; } }