How to ban IP access to HTTPS site (nginx)?
阿神
阿神 2017-05-16 17:27:35
0
3
855

How to prohibit IP from directly accessing HTTPS

The following settings are set in nginx:

server {
    listen 80;
    listen 443 ssl spdy;
    root /data0/web/domain.com;
    server_name domain.com *.domain.com;
    index index.html index.htm index.php;

    location / {
    }
}

##default
server {
    listen 80 default;
    listen 443 default;

    server_name _;

    root /data0/web/empty;

    location / {
        return 500;
    }
}

Set as above, access https://ip. SSL doesn't work. Even if you visit https://domain.com, you cannot access it.

阿神
阿神

闭关修行中......

reply all(3)
左手右手慢动作

It’s OK to use code like this

server 
        {
                listen 443 default;
                return 400;
        }
曾经蜡笔没有小新
server
{
    listen 443 ssl default_server;
    ssl_certificate      path_to_your_fullchain.cer;
    ssl_certificate_key  paht_to_your_key;
    return 301 https://demo.com;
}

Be sure to configure the ssl certificate, otherwise it will not work

黄舟
listen 80 default;
server_name domain.com *.domain.com;
...

if ( $host ~* "\d+\.\d+\.\d+\.\d+" ) {
    return 400;
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!