Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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;
        }

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

migrated from stackoverflow.com Aug 22 '11 at 19:37

This question came from our site for professional and enthusiast programmers.

2 Answers

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;
    }
share|improve this answer
    
Did not fix, unfortunately. I think the problem is with Wordpress. –  Zachary Burt Aug 21 '11 at 5:03
add comment

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/.

share|improve this answer
add comment

Your Answer

 
discard

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.