Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Multiple node.js on same server

$
0
0
Hi there. I'm a newbie with nginx and I'm trying to host two node.js apps (my own application on port 5000 and a mongo db manager on port 1234). I have created the CNAME entries on my DNS server to point to the same host (app.mydomain.com and mongo.mydomain.com). The application also uses https so I want to redirect http requests to https.

My configuration looks like this:

server {
listen 443;
server_name app.mydomain.com;

ssl on;
ssl_certificate /etc/nginx/ssl/app.mydomain.com.crt;
ssl_certificate_key /etc/nginx/ssl/app.mydomain.com.key;

location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}

server {
listen 80;
server_name mongo.mydomain.com;

location / {
proxy_pass http://localhost:1234;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Conenction 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}

server {
listen 80 default_server;
server_name app.mydomain.com;
return 301 https://$server_name$request_uri;
}

But when I browse to http://mongo.mydomain.com, I get a redirection to https://app.mydomain.com

What am I doing wrong?
Thank you in advance!

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>