Welcome! Log In Create A New Profile

Advanced

Redirects not working

Posted by rajindersingh 
Redirects not working
November 09, 2017 03:05PM
I am very new to using nginix.
I have it running in ubuntu 16.04 VM in AWS.
This ubuntu server is sitting behind AWS ALB.
I am trying to redirect some pages from 1 site to an external site.

ALB does path based routing.
If there is any request coming with local /es-mx I want to route to another server.
Here my complete setup

If I send a request like this

http://rzr-test.disco.com/es-mx

It does get routed to http://rzr-qa.disco.com/es-mx

Howerver, If I send a request like
http://rzr-test.disco.com/es-mx/page1 I expect it to be routed to
http://rzr-qa.disco.com/es-mx/page1

But it does not happen. It does not get redirected.
I have tested my paths in online nginx tester and they see to work but something is wrong my setup.


server {
listen 80;
server_name rzr-test.disco.com;
root /var/www/html;

location ~* ^/es-mx/ {
return 301 $scheme://rzr-qa.disco.com$request_uri;
}

location ~* ^/es-mx {
return 301 $scheme://rzr-qa.disco.com$request_uri;
}

location / {
}
}

server {
listen 80;
server_name rzr-qa.disco.com;

#rewrite ^/es-mx/(.*)$ /en-us/$1 last;
location / {
#rewrite ^/es-mx/(.*)$ /en-us/$1 last;
proxy_pass http://rzr-qa.disco.com;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header Proxy "";
proxy_cache_bypass $http_upgrade;
}
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 76
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready