frp内网穿透https非正常端口的nginx反代设置

2018年07月18日 656点热度 0人点赞 0条评论

最近在找反代方法,最后ngrok和frp中选择两者均可用。ngrok用作旧路由用,因为旧路由安装frp有问题。在frp用https协议的时候遇到nginx反代有问题,查找再三,终于找到了解决的办法。

server
{
        listen 443;
        ssl on;
#需按情况修改为真实证书路径
        ssl_certificate /www/ssl/pan.lovexu.ooo/fullchain.pem;        
        ssl_certificate_key /www/ssl/pan.lovexu.ooo/privkey.pem;       
        ssl_session_cache  builtin:1000  shared:SSL:10m;
        ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
        ssl_prefer_server_ciphers on;
        server_name pan.lovexu.ooo;
        location /
		{
        proxy_pass https://pan.lovexu.ooo:8443;  #frp代理地址和端口,需与frp配置文件中域名相同
        proxy_ssl_server_name on;
        proxy_ssl_session_reuse off;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Fprwarded-Proto $scheme;
        proxy_ssl_verify   off;
        proxy_redirect http:// $scheme://;
        proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        }

}

之前网上找了好多都是错误的,比如说下面这列:

server {
       listen 443;  
       server_name pan.lovexu.ooo;
       ssl on;       
       ssl_certificate /www/ssl/pan.lovexu.ooo/fullchain.pem;        
       ssl_certificate_key /www/ssl/pan.lovexu.ooo/privkey.pem;          
       ssl_session_timeout 5m;       
       ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;       
       ssl_protocols TLSv1 TLSv1.1 TLSv1.2;       
       ssl_prefer_server_ciphers on; 
       location /        
          {           
          proxy_pass https://127.0.0.1:8443;            
          proxy_redirect https://$host/ https://$http_host/;           
          proxy_set_header X-Real-IP $remote_addr;           
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;           
          proxy_set_header Host $host; 
          proxy_set_header X-Forwarded-proto https;
          }    
         }

 

LoveXu

保持饥渴的专注,追求最佳的品质

文章评论