Welcome! Log In Create A New Profile

Advanced

Nginx default_server catches all. Why?

Posted by toto 
Nginx default_server catches all. Why?
April 02, 2020 07:14AM
Hello all,

I have got 2 different URLs that are correctly redirected by Proxy_Pass.
However as soon as I add the default_server (first server below), my 2 URLs are not redirected anymore. They fall into the catch all.
Why is that? I don't understand what is wrong in the default configuration.
Thanks for your help!


# default server for this IP
server{
listen xx.xx.xx.xx:8443 default_server;
server_name _;
return 404;
}

server{
listen xx.xx.xx.xx:8443;
server_name *.staging1.xxxx.com staging1.xxxx.com;

ssl on;
ssl_certificate /etc/letsencrypt/live/mindbelts.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mindbelts.com/privkey.pem;

location / {
proxy_pass http://127.0.0.1:6981;
proxy_set_header Host $host;
}
}


server{
listen xx.xx.xx.xx:8443;
server_name *.staging2.yyyy.com .staging2.yyyy.com

ssl on;
ssl_certificate /etc/letsencrypt/live/mindbelts.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mindbelts.com/privkey.pem;

location / {
proxy_pass http://127.0.0.1:6982;
proxy_set_header Host $host;
}
}
Re: Nginx default_server catches all. Why?
April 02, 2020 07:16AM
I mixed up an xxxx and a yyyy when replacing the real addresses by fake ones. The configuration should read:


# default server for this IP
server{
listen xx.xx.xx.xx:8443 default_server;
server_name _;
return 404;
}

server{
listen xx.xx.xx.xx:8443;
server_name *.staging1.yyyy.com staging1.yyyy.com;

ssl on;
ssl_certificate /etc/letsencrypt/live/mindbelts.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mindbelts.com/privkey.pem;

location / {
proxy_pass http://127.0.0.1:6981;
proxy_set_header Host $host;
}
}


server{
listen xx.xx.xx.xx:8443;
server_name *.staging2.yyyy.com .staging2.yyyy.com

ssl on;
ssl_certificate /etc/letsencrypt/live/mindbelts.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mindbelts.com/privkey.pem;

location / {
proxy_pass http://127.0.0.1:6982;
proxy_set_header Host $host;
}
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 77
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready