I verified my stack works I can get a phpinfo() dump in a test file and I can get static files to load like css files.

I can not however get wordpress to work. Here's the issue:

Wordpress redirects the domain but the domain will always have at least two different versions: one for the nginx and one for the apache. Because they are different ports:

https://example.com <= Default that I set nginx to http://example.com:8080 <= loaded through apache

If I set my site url and home page url to either, I get a redirect loop, the only difference is what is going to be in the location it redirects to.

HTTP/1.1 301 Moved Permanently
Date: Tue, 16 Apr 2019 02:12:23 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Redirect-By: WordPress
Location: https://example.com/

If I set the site url to http://example.com:8080 and go to that address (load thorugh apache skipping nginx) the site works. But there is no way for it work through nginx I have found.

It seems no matter what I pass it will not like it. Yet other php files work fine. My settings for nginx:

location ~ \.php$ {
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;


Again it works for anything I load that is basic but wordpress redirects.

I have tried using:


which both say they fix this issue by disabling redirects but it doesn't work.

I have tried using more proxy_set settings for nginx others have suggested but they don't work to fix it either:

server_name_in_redirect off;
sendfile off;
proxy_redirect off;

I have tried using $http_host and $http_post:8080 too which did not work. Yet most guides I find on this seem to do way less than I have with the same settings and they say their wordpress doens't have this issue. So I tried installing a new wordpress on a new vhost. It also doesn't work.

If I set the site url to match apache or nginx and use only apache or nginx, it works. But that defeats the entire purpose of reverse proxy.

Edit: finally got it to work by looking here: https://stackoverflow.com/questions/12253539/wordpress-redirect-loop-on-site-root-nginx-proxy-apache

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.