Welcome! Log In Create A New Profile

Advanced

Multiple node.js on same server

Posted by jselesan 
Multiple node.js on same server
March 07, 2016 02:42PM
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!
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 342
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready