6

Why is http://compassionpit.com/blog/ going through an infinite redirect loop? Here's my nginx conf file. The site is run by a nodejs server on port 8000 and Apache serves up the blog (wordpress) and the forum (phpBB). The forum is resolving just fine, at http://www.compassionpit.com/forum/ ...

 server {
        listen          80;
        server_name     www.compassionpit.org;
        rewrite         ^/(.*) http://www.compassionpit.com/$1  permanent;
    }


    server {
        listen       80;                # your server's public IP address
        server_name  www.compassionpit.com;
        index        index.php index.html;

        location ~ ^/$ {
            proxy_pass http://127.0.0.1:8000;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        location @blogphp {
            internal;
            root /opt/blog/;
            include fastcgi_params;
            fastcgi_param  SCRIPT_FILENAME  $document_root/index.php;
            fastcgi_index  index.php;
            fastcgi_pass   127.0.0.1:8080;
        }

        location ~ ^/(forum|blog)/($|.*\.php) {
            root /opt/;
            include fastcgi_params;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_index  index.php;
            fastcgi_pass   127.0.0.1:8080;
        }

        location ~ ^/(forum|blog) {
            root /opt/;
            try_files $uri $uri/ @blogphp;
        }

        location ~ ^/(forum|blog)/ {
           root /opt/;
        }


        location @backend {
            internal;
            proxy_pass http://127.0.0.1:8000;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        location ~ / {
            root /opt/chat/static/;
            try_files $uri $uri/ @backend;
        }

    }
3
  • 1
    Nice to see you are using my answer stackoverflow.com/questions/5815305/… Aug 10, 2011 at 11:27
  • @Alexander Azarov thanks for reminding me i gave you credit
    – Zachary Burt
    Aug 11, 2011 at 17:40
  • IMO This question is more suitable for ServerFault
    – Darhazer
    Aug 22, 2011 at 18:18

2 Answers 2

2

I think you probably have Wordpress configured without the 'www' subdomain in it's URLs, and this is conflicting with the way you have Nginx configured (with server_name www.compassionpit.com).

So, when you visit compassionpit.com/blog/ Nginx redirects you to www.compassionpit.com/blog/, this request then hits Wordpress which redirects you back to the bare domain compassionpit.com/blog/.

0

Nginx is possibly carrying on to process the other if statements. Add a "break" at the end of the if statements

location ~ ^/(forum|blog)/($|.*\.php) {
        root /opt/;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_index  index.php;
        fastcgi_pass   127.0.0.1:8080;
        break;
    }
1
  • Did not fix, unfortunately. I think the problem is with Wordpress.
    – Zachary Burt
    Aug 21, 2011 at 5:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .