0

I am trying to write an nginx.conf which will redirect to port 3001 where meteor.js TEST env is of my EC2 instance. If user types "xxx.xxxx.com/test". Redirection isn't working and it searches pages from my meteor.js app.

Nginx and meteor.js app are in docker containers.

nginx.conf:

events{

}

http{}
    server {
        listen *:80;
        server_name xxxxx.xxxx.com www.xxxxx.xxxx.com;

        location / {
            proxy_pass http://xxxxx.xxxx.com:3000;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   Host $http_host;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        location /test/ {
            proxy_pass http://xxxxx.xxxx.com:3001;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   Host $http_host;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }
} 

How to make a proper redirection(I am very new to nginx). Thank you in advance!

1 Answers1

1

Move location /test/ above location /. That should do the trick. With your cureent setup, requests with /test will be matched first in location /, and nginx will never look into other locations.

Kelzier
  • 39
  • 5
  • `/` - is for PROD. How PROD(port 3000) will be available? I need those 2 to be available at the same time – DimonVersace Aug 12 '16 at 10:02
  • I got your point. `location / { proxy_pass http://studio.accenture.com:3000; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; location /test/ { proxy_pass http://studio.accenture.com:3001; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }` – DimonVersace Aug 12 '16 at 10:07
  • It still tries to find a page called "test" in PROD app – DimonVersace Aug 12 '16 at 10:08