V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
wxlg1117
V2EX  ›  问与答

有人配置成功过 nginx 反代 frp 的 https 嘛?

  •  
  •   wxlg1117 · 2017-07-27 16:00:02 +08:00 · 10755 次点击
    这是一个创建于 2437 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我怎么配置打开都是报 502 错误,frps 显示下面这个错误:
    [vhost.go:131] get hostname from http/https request error: Unknow error...


    PS:nginx 反代 frp 的 http 是没问题的
    13 条回复    2020-09-08 16:24:00 +08:00
    hteen
        1
    hteen  
       2017-07-27 16:39:42 +08:00   ❤️ 2
    我是 nginx frp 走 http, nginx 对外用的 https
    oh
        2
    oh  
       2017-07-27 16:39:50 +08:00
    把 https 加在 nginx 层,frp 用 http 呢?
    oott123
        3
    oott123  
       2017-07-27 16:57:39 +08:00 via Android
    proxy_header Host $http_host;
    oott123
        4
    oott123  
       2017-07-27 16:58:10 +08:00 via Android
    proxy_set_header,刚刚打错了
    wxlg1117
        5
    wxlg1117  
    OP
       2017-07-27 17:27:02 +08:00
    @oh 这个也没问题的
    Showfom
        6
    Showfom  
       2017-07-28 07:29:17 +08:00 via iPhone
    弱弱的问下 frp 是神马
    wxlg1117
        7
    wxlg1117  
    OP
       2017-07-28 15:33:34 +08:00
    设置过这个,也还是出错的
    lcl1995225
        8
    lcl1995225  
       2018-07-26 22:18:03 +08:00
    @wxlg1117 您好,这个问题解决了吗……我也遇到了这个问题,按照网上的教程试了“ ngx_http_proxy_connect_module ” 还是无解。
    sf1991
        9
    sf1991  
       2018-08-09 03:24:46 +08:00
    我解决这个问题了:

    [NGINX HTTPS and FRPS · Issue #610 · fatedier/frp]( https://github.com/fatedier/frp/issues/610)

    [nginx https 转发 frps · Issue #671 · fatedier/frp]( https://github.com/fatedier/frp/issues/671)

    你先参考这两个。

    我的代理:

    ```
    server {
    listen 80;
    listen 443 ssl http2;

    ssl_certificate /usr/local/nginx/conf/ssl/x.xxx.cn.crt;
    ssl_certificate_key /usr/local/nginx/conf/ssl/x.xxx.cn.key;

    server_name x.xxx.cn;

    location / {
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_ssl_server_name on;
    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;
    #看来这里要写死域名才行啊
    proxy_pass https://x.xxx.cn:8080;
    }
    }
    ```

    我这是为了解决:80 的 http/https 代理到 8080 的 http/https 上去,为了实现隐藏 8080 端口,因为 frp 绑定不论 80 端口,被占用了,所以 frp 只能使用 8080,而我这个代理就是为了隐藏 8080。

    tip: 如果只是 http 的代理很容易,但是当我是 https 时,一样的 nginx 代理配置,frp 就不行了,虽然还没有找到真正的问题,但以上 nginx 代理配置也解决了我目前的问题。更多参见:[反向代理 · web 开发最佳实践 · 看云]( https://www.kancloud.cn/xiak/web-dev-best-practice/708208) #https 时的代理
    darkt
        10
    darkt  
       2018-11-28 02:43:19 +08:00
    @sf1991 你好 问下 我现在部署了 frp 占用了 80 和 443 端口
    现在想要实现 frp 里面绑定的泛域名 自动加 SSL 证书
    现在是要安装 nginx 然后配置文件该怎么写呢 80 和 443 端口被占用 NGINX 肯定要换端口了
    raymondzhou
        11
    raymondzhou  
       2019-02-12 08:57:54 +08:00   ❤️ 1
    @darkt 我成功实现了 frp 和 nginx 共存,nginx 反向代理 frp 并实现全程 https
    具体方法见这个链接
    https://blog.ray8.cc/archives/nginx-frp-https-wildcard.html
    AllenHua
        12
    AllenHua  
       2019-12-23 13:38:40 +08:00
    @raymondzhou #11 层主... 可不可以加个联系方式 交流学习下
    AllenHua
        13
    AllenHua  
       2020-09-08 16:24:00 +08:00
    前几天弄了下 成功了 同 1 楼 frp 走 http, nginx 包裹一层 ssl
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2832 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 710ms · UTC 14:36 · PVG 22:36 · LAX 07:36 · JFK 10:36
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.