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 have implemented load balancer using nginx as below:

upstream lb_units {
  server weight=7 max_fails=3 fail_timeout=30s; # Reverse proxy to  BES1
  server weight=1 max_fails=3 fail_timeout=30s; # Reverse proxy to  BES2
  server weight=1 max_fails=3 fail_timeout=30s; # Reverse proxy to  BES2
server {
 listen 80; 
 location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_pass         http://lb_units; 
    proxy_redirect off;
#########FINALLY THE REAL SITE##############
server {
    listen   88 backlog=128 default_server;
    rewrite  ^/en/businesses$             /en/business permanent;
    location / {
        proxy_redirect    off;


now whenever i try to browse /en/businesses page, it redirects me to port 88 (ie.: How can i force nginx to keep on port 80 when it runs the rewrite rule (ie. to make rewrite to

share|improve this question
up vote 2 down vote accepted

Since your server block is listening on port 88 and you used a relative URL in your rewrite, nginx uses port 88 in the resulting URL.

To fix this, specify the complete URL. For example:

        rewrite  ^/en/businesses$    permanent;
share|improve this answer
Then the redirect is probably coming from your application. Check the application and make sure it is configured to construct URLs using port 80 rather than 88. – Michael Hampton Jan 7 '13 at 16:16

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.