Score:0

nginx: prevent open first available site on different port

jp flag

Here is an example configuration.

    server {
    listen 8080;
    server_name a.x.com;
    ...
}

server {
    listen 8081 ssl;
    server_name a.x.com;
    ...
}       

    
server {
    listen 80;
    server_name  b.x.com;
}   

server {
    listen 443 ssl;
    server_name b.x.com;
    ...
}               

#supposedly the default folder  
server {
    #https://stackoverflow.com/a/9454825/4546246
    listen       80 default_server;
    #listen       443 default_server;
    server_name  ~^(.+)$;
    location / {
        root   html;
        index  index.html index.htm;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}

open htpps://a.x.com:8081 -> (NO PROBLEM) open https://b.x.com -> (NO PROBLEM)

but

open https:/a.x.com (without port) -> it's opening the files of b.x.com.

supposedly what was expected was to open the html folder

where am I doing wrong?

Score:2
in flag

You haven't defined a server block for a.x.com for the port 443. The only server block you defined for port 443 is b.x.com, so that's what you are getting.

jp flag
I'll try tomorrow and inform you. Thank you for the answer.
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.