Question
Nginx subdomain and domain multiple server name configuration
I’m trying to configure multiple server block in nginx but stuck at getting one endpoint working, below is my first site setup and it’s working :
server {
listen 80;
server_name app.example.com;
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;
proxy_cache_bypass $http_upgrade;
}
}
my subdomain file located at
home/app/index.html
Then I want to do for the another one, I add a folder call site means it host my static site at example.com
server {
listen 80;
server_name example.com;
location /site {
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;
proxy_cache_bypass $http_upgrade;
}
}
my main domain file located at
home/site/index.html
I got a bad gateway 502 error.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×