Skip to content

Update Nginx configuration for PHP handling#61

Merged
Ym0T merged 2 commits intoYm0T:mainfrom
Frerduro:patch-1
Apr 11, 2026
Merged

Update Nginx configuration for PHP handling#61
Ym0T merged 2 commits intoYm0T:mainfrom
Frerduro:patch-1

Conversation

@Frerduro
Copy link
Copy Markdown
Contributor

Fixes #39 and allows NGINX to serve 404 pages again.

Fixes #39 and allow NGINX to serve 404 pages again.
Copilot AI review requested due to automatic review settings April 10, 2026 20:36
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the default NGINX virtual host to prevent unwanted absolute redirects (including port leakage) and to tighten/adjust PHP request handling so missing PHP scripts can correctly return 404.

Changes:

  • Disable absolute redirects and suppress ports in redirect responses (absolute_redirect off, port_in_redirect off).
  • Add a try_files guard in the PHP location to return 404 for non-existent PHP scripts.
  • Enable fastcgi_intercept_errors to allow NGINX to handle upstream error statuses (where configured).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread nginx/conf.d/default.conf
Comment on lines 25 to 28
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/home/container/tmp/php-fpm.sock;
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new try_files $uri =404; in the PHP location will 404 valid requests that include PATH_INFO (e.g. /index.php/some/path) because $uri includes the extra path segment and won’t exist on disk. If you want to prevent executing non-existent scripts while still supporting PATH_INFO-style routing, switch the existence check to the script name (e.g. $fastcgi_script_name) and ensure PATH_INFO is passed through consistently with fastcgi_split_path_info.

Copilot uses AI. Check for mistakes.
@Frerduro
Copy link
Copy Markdown
Contributor Author

perhaps changing it to this would curb it's complaining. I need to do some testing.

try_files $fastcgi_script_name =404;

@Ym0T Ym0T self-assigned this Apr 11, 2026
- Move fastcgi_split_path_info before try_files so $fastcgi_script_name
  is populated before the existence check runs
- Use $fastcgi_script_name instead of $uri to correctly handle PATH_INFO
  requests (e.g. /index.php/some/path) without returning false 404s
@Ym0T
Copy link
Copy Markdown
Owner

Ym0T commented Apr 11, 2026

Thanks for the contribution! I applied the changes manually with a small adjustment: using $fastcgi_script_name instead of $uri in the try_files check, as Copilot correctly pointed out that $uri would cause false 404s for PATH_INFO-style requests. I also moved fastcgi_split_path_info before try_files to ensure the variable is populated before the check runs.
Thanks again for fixing the redirect and 404 handling!

@Ym0T Ym0T self-requested a review April 11, 2026 23:52
@Ym0T Ym0T merged commit 0fe85e2 into Ym0T:main Apr 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Can't connect into my wp-admin

3 participants