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

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

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.