Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Anyone know how to fix an issue with Nginx + Apache + Wordpress redirecting to localhost/ I've tried a lot of different fixes, but none have worked for me.

I can go to just fine and use everything there normally. But if I try to go to it redirects to Everything also works fine if I just run through Apache.

Here are the relevant portions of my nginx.conf:

server {                                
    listen 80;           
    root /var/www/html/wordpress;       

    location / {                      
        try_files $uri $uri/ /index.php;

    location ~ \.php$ {

Here are the relevant portions of my httpd.conf:

Listen *:8080

ServerName <ip>

<VirtualHost *:8080>
    ServerAdmin test@test
    DocumentRoot /var/www/html/wordpress

This is what my nginx log loks like:

<ip> - - [19/Jun/2012:22:35:35 +0400] "GET / HTTP/1.1" 301 0 "-" "Mozilla/5.0

This is what my httpd log looks like: - - [19/Jun/2012:22:24:46 +0400] "GET /index.php HTTP/1.0" 301 - "-"


WordPress Address (URL) and Site Address (URL) both have same

Adding proxy_set_header Host $host; results in "This webpage has a redirect loop."

It also works if I use

location / {
  proxy_set_header Host $host;

but not with any try_files statements that fall through to other locations.

share|improve this question

This is an old question, but as I come across...

 location ~ \.php$ {

It's not enough to proxy requests to WordPress. Basically, you should do it the other way around :

Send all static file requests to Nginx explicitly :

location ~ \.(css|js|ico|jpg|jpeg|png|gif|svg|pdf)$ {
    try_files $uri $uri/ /index.html;

Then proxy the rest to Apache :

location / {
    proxy_set_header Host $host;
share|improve this answer

This is probably not a server issue

go to after login into dashboard and make sure Site Address (URL) is same as WordPress Address (URL) .

share|improve this answer
I considered that. WordPress Address (URL) and Site Address (URL) both have same – jcrcj Jun 19 '12 at 19:48

Please set proxy_redirect off; in your location ~ \.php$ block. For more info, please check out the official documentation proxy_redirect.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.