Answer the question
In order to leave comments, you need to log in
How to set up nginx config for 2 nodejs applications (domain and subdomain)?
Launched 2 applications. One on port 3000, the other 5000.
nginx config:
server {
listen 80;
listen [::]:80;
server_name example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
include snippets/ssl-example.com.conf;
include snippets/ssl-params.conf;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
}
location /.well-known {
root /home/ubuntu/again/222/static;
}
}
server {
listen 80;
listen [::]:80;
server_name old.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
include snippets/ssl-example.com.conf;
include snippets/ssl-params.conf;
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;
}
}
Answer the question
In order to leave comments, you need to log in
I have so:
server {
listen 80;
server_name api.domain.ru www.api.domain.ru;
proxy_set_header Host api.domain.ru;
location / {
rewrite ^(.*)$ https://api.domain.ru$1 permanent;
}
return 301 https://api.domain.ru$request_uri;
}
server {
listen 443 ssl http2;
server_name api.domain.ru www.api.domain.ru;
#......................
}
#################################################################
server {
listen 80;
server_name domain.ru www.domain.ru;
proxy_set_header Host domain.ru;
location / {
rewrite ^(.*)$ https://domain.ru$1 permanent;
}
return 301 https://domain.ru$request_uri;
}
server {
listen 443 ssl http2;
server_name domain.ru www.domain.ru;
#.......................
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question