近期工信部大动作,干了一批未备案的站点,博主包括本站在内,线上所有未备案的站点都被干掉了,全部提示需要备案。

但是因为博主不知为何就是非常的抗拒备案一事,所以想到使用nginx反向代理绕过备案,google一番后发现已有前人实现,说明是可行的。


先来说说我最开始的绕过备案想法:

1、使用https访问绕过备案,http强制跳转https。(优点:直接访问https速度快  缺点:无法强制http跳转)

2、使用nginx反向代理(优点:支持http及https访问  缺点:访问速度较慢,需要使用跳板vps)


经过测试,直接访问https是可以成功绕过备案的,但是却无法实现http强制跳转https,所以方案1并不友好。

最后选择了使用方案2

方案2的简单nginx配置如下:

跳板vps:

server
    {
        listen 80;
        server_name markss.club;
            return 301 https://$host$request_uri;
    }
server
    {
        listen 443 ssl http2;
        #listen [::]:443 ssl http2;
        server_name markss.club ;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/markss.club;
        ssl on;
        ssl_certificate /etc/letsencrypt/live/markss.club/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/markss.club/privkey.pem;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_ciphers "EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
        ssl_session_cache builtin:1000 shared:SSL:10m;
        # openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
        ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;
    location / {
            proxy_pass            http://119.29.240.194:8088;
            proxy_redirect          off;
            proxy_set_header        X-Real-IP       $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            }
        location ~ /.well-known {
            allow all;
        }
        access_log off;
    }


站点vps:

server
    {
        listen 8088;
        #listen [::]:80;
        server_name localhost;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/markss.club/public;
        include other.conf;
        #error_page   404   /404.html;
        include enable-php.conf;
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }
        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }
         location / {
             try_files $uri $uri/ /index.php$is_args$args;
             }
        access_log  /home/wwwlogs/markss.club.log;
    }



如果不需要使用https访问的话跳板的nginx配置如下:

server
    {
        listen        80;
        server_name     markss.club;
        location / {
            proxy_pass            http://119.29.240.194:8088;;
            proxy_redirect          off;
            proxy_set_header        X-Real-IP       $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            }
    }

简简单单的几行代码便能绕过备案,缺点就是增加了访问速度的消耗,需要使用一台vps作为跳板访问。