if you want to disable IP access, the http access redirection https, function has been implemented, but there are the following problems
- nginx-t report waring
- do I need to add default_server after lissten 80?
nginx: [warn] conflicting server name "_" on 0.0.0.0:80, ignored
server {
listen 80;
server_name _;
return 500;
}
server {
listen 80;
server_name www.domain.com;
rewrite ^(.*)$ https://$host$1 permanent;
}
server {
listen 443 ssl;
server_name www.domain.com;
-sharp ssl
ssl on;
ssl_certificate 1_.club_bundle.crt;
ssl_certificate_key 2_.club.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
-sharp Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
root /www/blog;
index index.html;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}