Score:0

Creating a new reverse proxy configuration in Nginx routes to a different config

jp flag

I have been banging my head on the wall with this. Any help that can be offered would be greatly appreciated.

I have handful of websites/services running on various different servers. I have a reverse proxy running on a server here at home to route different subdomains to their destinations elsewhere. I create a new conf, I indicate where my proxy_pass should be going to. My /etc/nginx/conf.d has the many different configs but to keep it simple, let's say I have these three:

a.conf
b.conf
c.conf

Let's say c.conf is the new one I've created/working on setting up. Here is it's contents:

server {
  listen 80;
  server_name newsubdomain.root.net;

  location / {
      proxy_pass http://222.222.222.222:4011;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

      #upgrade to WebSocket protocol when requested
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "Upgrade";
  }

}

where http://222.222.222.222:4011 is my (obfuscated) destination.

When navigating to newsubdomain.root.net, I end up landing at the proxy_pass that was configured in a.conf. While trying to troubleshoot, I've renamed a.conf to a.conf.bak. Now when navigating to newsubdomain.root.net, I am landing at the proxy_pass that is defined in b.conf.

It has to be something simple that I am missing but I'm at a loss at this point. I've setup tons of new configs this way (20+ on this server) with no issue and nothing has changed since then (at least to my knowledge, I'm the only one who accesses this server.)

I've searched for a solution to this but my search terms are not rendering anything pertinent. I am happy to provide any logs/additional information needed.

Thanks in advance to anyone who can lend some advice.

cn flag
Could you check if you have `default_server` option for `listen` directive on any of your virtual hosts?
sammo22 avatar
jp flag
`grep -r default_server /etc/nginx` only shows in sites-available but not enabled or anywhere else.
djdomi avatar
za flag
it was meaned if you have some kind of catchall, however show pls `nginx -tT`
sammo22 avatar
jp flag
Other than changing domain names and IPs for privacy, this is what I've got. https://pastebin.com/BHLTJjNz (Output was wayy to long for a comment)
cn flag
@sammo22 besides the fact that your nginx config looks like a mess (sorry for that), I advice you just to inspect everything from scratch and create basic default nginx config with single virtual host, then to add virtual hosts one-by-one until you find your problem.
Richard Smith avatar
jp flag
When it shows the other domains - has the browser's address bar changed at all? It may be jumping to an invalid domain name or jumping to `https`. You should test the server with `curl -I http://newsubdomain.example.net`
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.