Answer the question
In order to leave comments, you need to log in
How to leave default IP address free when configuring virtual host redirect in NGINX?
The bottom line is this:
There is a server with virtual hosts and one IP (xxx.xxx.xxx.xxx)
There is the following virtual host setting:
server {
listen 80;
server_name www.domain.com domain.com;
return 301 https://domain.com$request_uri;
}
server {
listen 443 ssl;
server_name domain.com;
....
}
server {
listen 80 default_server;
server_name xxx.xxx.xxx.xxx;
}
server {
listen 80;
server_name www.domain.com domain.com;
return 301 https://domain.com$request_uri;
}
server {
listen 443 ssl;
server_name domain.com;
....
}
Answer the question
In order to leave comments, you need to log in
What strange things are happening)
in the /etc/nginx/sites-available/default file I have:
server {
listen 80 default_server;
server_name xxx.xxx.xxx.xxx;
}
listen xxx.xxx.xxx.xxx:80 default_server;
server_name "_";
listen 80 default_server;
server_name "_";
server {
listen 80;
server_name www.domain.com domain.com;
return 301 https://domain.com$request_uri;
}
server {
listen 443 ssl;
server_name domain.com;
....
}
server {
listen xxx.xxx.xxx.xxx:80;
server_name www.domain.com domain.com;
return 301 https://domain.com$request_uri;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question