用 nginx 反向代理 https 站点(SNI)

新注册了 drserver.cn 的域名,首先是想到放国内,因为访问速度快。但一想到ICP备案,打算域名访问到境外的机子,但通过反向代理浏览国内机子的内容。

环境:debian 9,nginx;国内站点访问 drserver.anqun.org

过程:

1.apt install nginx # 境外debian9上安装好nginx
nginx-reserv-ssl-1.png

2.vi /etc/nginx/sites-enabled/drserver.cn # 创建drserver.cn站点配置文件,内容如下。请根据情况调整SSL证书,主机名等参数

server {
        listen 80;
        listen 443 ssl http2;  # your server's public IP address
        server_name  drserver.cn www.drserver.cn;      # your domain name

        ssl on;
        ssl_certificate           /etc/nginx/ssl/drserver.cn.pem;
        ssl_certificate_key       /etc/nginx/ssl/drserver.cn.key;

        location / {
          # proxy_ssl_name $host;
          proxy_ssl_server_name on;
          proxy_pass         https://drserver.anqun.org;
          # proxy_redirect     off;
          # proxy_set_header   Host             $host;
          proxy_set_header   X-Real-IP        $remote_addr;
          proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
          proxy_set_header        X-Forwarded-Proto $scheme;
        }
}

3.systemctl restart nginx # 保存好站点配置文件后重启nginx

4.访问测试,正常
nginx-reserv-ssl-2.png

参考:

标签: nginx

添加新评论