Report this

What is the reason for this report?

Nginx subdomain and domain multiple server name configuration

Posted on March 1, 2016

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.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.