Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi there,
The issue you’re facing with your WordPress site when using Nginx as a reverse proxy likely stems from an improper configuration of the location / block in your Nginx configuration. Specifically, the try_files directive seems to be misconfigured for handling WordPress’s pretty permalinks.
In a typical WordPress setup, the index.php file should handle all requests that do not correspond to actual files or directories on the server. This is especially important for WordPress permalinks, which use a more SEO-friendly URL structure.
Here’s how you can modify your Nginx configuration to properly handle WordPress permalinks:
Remove the try_files $uri $uri/ =404; Line: This line is currently telling Nginx to try to serve the request as a file, then as a directory, and if neither is found, return a 404 error. This is problematic for WordPress permalinks.
Update the location / Block: Replace the try_files line with a directive that forwards all requests to WordPress’s index.php file, unless the request is for a real file or directory.
Here’s an updated version of your location / block:
location / {
proxy_pass https://example.com;
proxy_ssl_server_name on;
# Correctly handle requests for WordPress permalinks
try_files $uri $uri/ /index.php?$args;
}
In this configuration:
try_files $uri $uri/ /index.php?$args; tells Nginx to first check if the requested URI corresponds to a real file ($uri) or directory ($uri/). If neither is found, it then rewrites the request to index.php, passing the query arguments ($args). This setup is necessary for WordPress to correctly interpret and route permalinks.Ensure SSL Configuration and Certificates: Make sure your SSL certificates and keys are correctly specified and the paths are correct.
Reload Nginx Configuration: After making these changes, reload the Nginx configuration to apply them:
sudo nginx -t
sudo systemctl reload nginx
Also ensure that WordPress is configured to use permalinks. You can check this in the WordPress admin area under Settings > Permalinks.
This configuration should resolve the 404 errors you’re encountering with WordPress posts and category pages when accessing them through your Nginx reverse proxy.
Best,
Bobby