I am trying to redirect calls from 127.0.0.1:3001
to subdomain.example.com
but I am unable to achieve this. It only works when I add port to the domain i specified. subdomain.example.com:3001
this works. How do I ignore the port.
Below is my conf
upstream backend {
server 127.0.0.1:3001;
}
server {
listen 80;
server_name subdomain.example.com;
location / {
proxy_pass http://backend/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forward-Proto http;
proxy_set_header X-Nginx-Proxy true;
proxy_redirect off;
}
}
This is hosts configuration at /etc/hosts
127.0.0.1 localhost
123.456.789.0 subdomain.example.com
Is there anything that I am missing, I just couldn't figure out how to get the port to be ignored.