If you are running two node apps it could be done using this NGINX config. Just make sure app1 and app2 are on different ports.
server {
listen 80;
server_name localhost;
location /app1 {
proxy_pass http://127.0.0.1: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;
}
location /app2{
proxy_pass http://127.0.0.1:5001;
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;
}
}
EDIT: This is how I have multiple sites running *note: server name should be set to the domain, but if you dont have access to domains set them as the IP:PORT shown in example below! Reason why server name cannot be local is it needs to be public for access. In my use case for website 1 server_name is website1.com then website 2 server_name is website2.com (My domains)
server {
listen 5000;
//APP 1
server_name 10.0.0.1:5000;
location /{
proxy_pass http://127.0.0.1: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 5001;
//APP 2
server_name 10.0.0.1:5001;
location /{
proxy_pass http://127.0.0.1:5001;
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;
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…