Sign up ×
Server Fault is a question and answer site for 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, and the backend box is 456.456.456.456. So I have this config:

upstream backend {
    server 456.456.456.456;

server {
    listen       80;

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

1 Answer 1

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

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.