By eldy8888
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.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello @ryanpq and all, is this thread still monitored? I’m having a lot of trouble getting my sub domain up and running after getting SSL and all the other tutorials I followed have threads that are no longer monitored. Support is not really offering me any help either. I’m getting the 502 error, everything works fine for my primary domain and it’s using the exact same setup (they’re both using the same node app - obviously proxied to a different port on localhost and I changed the server name). If you’re there please let me know and I’ll post my server blocks, any help would be awesome!!
The second configuration you created does not handle requests for example.com. It only routes traffic directed at example.com/site to your directory. The location line specifies a location relative to the document root in the request. You should either add a root to route other requests to static files or change location /site to location /
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.