0

I've have two server blocks, testing with different server_name but same destination.

server {
    listen 80;
    server_name api.x.com;

    location / {
            proxy_pass http://localhost:3000;
    }
}

server {
    listen 80;
    server_name y.io;

    location / {
            proxy_pass http://localhost:3000;
    }
}

the first server block (api.x.com) works as expected. however y.io is returning 404. regardless if i'm trying to proxy_pass or sending back static index.html

Both domain have the same DNS configuration (if i remove the server_block for y.io, than y.io will give me the default nginx welcome page.)

How should i debug this?

1 Answer 1

1

Start by looking at your Nginx error logs. Next check the logs for whatever is listening on port 3000 to see if the request is arriving, and if so the logs / error logs for what it's doing.

If you need to debug Nginx location as I outline in this article, which requires headers more to be installed into your Nginx. If it's not compiling Nginx is fairly simple. Your location could look like this

server {
  listen 80;
  server_name y.io;

  location / {
    add_header X_LOCATION1 "yes";
    proxy_pass http://localhost:3000;
    add_header X_LOCATION2 "yes";
  }
}

You can add variables as well if you need to.

2
  • Thanks Tim, apparently the CNAME record created at the provider zone config does not get updated for at least 3 hours. but your guide is very comprehensive. thanks
    – devric
    Jul 9, 2018 at 9:14
  • A new CAME is usually immediate. A change can take 5 minutes to 2 days, usually in the 2-4 hour range. Depends on caching and such.
    – Tim
    Jul 9, 2018 at 21:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .