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.

I'm trying to use nginx as a load balancer, and it's working great. One problem, though.

The load balancing box is at 123.123.123.123, and the backend box is 456.456.456.456. So I have this config:

upstream backend {
    server 456.456.456.456;
}

server {
    listen       80;
    server_name  123.123.123.123;

    access_log  off;
    error_log off;

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

This works great. I hit 123.123.123.123 in my browser, and the page comes up. But now the URL in the browser says http://456.456.456.456.

Do I need to use a rewrite rule or something to keep the url correct? I don't want it to be different when going to different backed servers. None of the tutorials I've read have mentioned anything about this.

share|improve this question
add comment

1 Answer

As it turns out, this was a situation where my app was set up to initially redirect, and that was causing the issue.

share|improve this answer
    
there is also proxy_redirect derective in nginx –  SaveTheRbtz Jan 28 '10 at 15:02
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.