0

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

2

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;
  • 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 clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.