Skip to main content

nginx serves wrong domain site. It doenst shows default site if no configuration applies [Resolved]

I have 3 domains that are pointing to my server and the server runs confluence and jira application from atlissan.

For whatever reason, my nginx is acting strange.

I have the default nginx configuration not touched. If I visit test.doamin.com, nginx shows me the default nginx page.

I have a configuration for jira that is enabled in the sites-enabled:

server {
   listen jira.domain.com:443 ssl;
   server_name jira.domain.com;
   server_tokens off;
   location / {
       proxy_set_header Host $server_name;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forewarded-For  $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Proto $scheme;
       proxy_set_header Authorization "";
       proxy_pass       http://127.0.0.1:8080; #Jira port
   }

   # certbot ssl settings
   #htaccess settings
}

server {
    if ($host = jira.domain.com) {
        return 301 https://$host$request_uri;
    }
    listen jira.domain.com:80;
    server_name jira.domain.com;
    return 404;
}

Now, If I visit jira.domain.com, I am getting jira served.

That are my only two configurations. The point is, that I am getting jira served, even if I visit from confluence.domain.com. If I change the port in the proxy pass to the confluence port, I am getting confluence served. Why is nginx picking up if I come from confluence.domain.com? Even Jira tells me that I am comming from confluence.domain.com.

all domain entries are A records to the IP of the server


Question Credit: Patrick Schocke
Question Reference
Asked July 13, 2019
Tags: nginx
Posted Under: Network
11 views
2 Answers

nginx documentation doesn't tell that it supports domain names in listen directives. You should only use port number there, unless you have a specific need to bind nginx only to a specific interface.


credit: Tero Kilkanen
Answered July 13, 2019
Your Answer
D:\Adnan\Candoerz\CandoProject\vQA