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

upstream lb_units {
  server 127.0.0.1:88 weight=7 max_fails=3 fail_timeout=30s; # Reverse proxy to  BES1
  server 10.200.200.107 weight=1 max_fails=3 fail_timeout=30s; # Reverse proxy to  BES2
  server 10.200.200.94 weight=1 max_fails=3 fail_timeout=30s; # Reverse proxy to  BES2
}
server {
 listen 80; 
 server_name  mysite.com; 
 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.: http://mysite.com:88/en/business) How can i force nginx to keep on port 80 when it runs the rewrite rule (ie. to make rewrite to http://mysite.com/en/business)?

share|improve this question

1 Answer 1

up vote 1 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$             http://mysite.com/en/business 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

 
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.