Nginx只允许域名访问网站,禁止使用IP访问80,443端口

#在原本server段末尾添加
server 
{
    listen 80 default;
    listen 443 default_server;
    server_name _;
    return 403;
    ssl_certificate /etc/ssl/cert.pem;
    ssl_certificate_key /etc/ssl/key.pem;
    ssl_session_timeout 5m;#  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    ssl_prefer_server_ciphers on;

}

我来吐槽

*

*