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

有用 frp 的吗,请教个问题

  •  
  •   ProjectSky · 2019-06-27 20:24:31 +08:00 · 3215 次点击
    这是一个创建于 1757 天前的主题,其中的信息可能已经有所发展或是发生改变。

    这两天被这个 frp 转发问题搞的头大了。

    手头有两台云服务器,一台腾讯云,一台阿里云,阿里云使用 frps,frpc 连接后没有任何问题,https 页面可以正常打开。

    但是腾讯云同样的 frps 和客户端的 frpc 配置,只能访问 http 端口,不能访问 https 端口,后台也可以看到 frpc 访问的日志,但是就是不能打开 https 页面。

    • frps 日志
    [https] join connections, workConn(l[172.27.0.16:7000] r[x.x.x.x:40688]) userConn(l[172.27.0.16:443] r[x.x.x.x:51612])
    

    但是我发现腾讯云本机可以正常访问 https 服务,外部就是不行,端口已经全部打开了。

    • 本机访问 fprs 日志
    [proxy.go:221] [78a21caf9e2b36d8] [https] join connections, workConn(l[172.27.0.16:7000] r[x.x.x.x:39712]) userConn(l[172.27.0.16:443] r[x.x.x.x:52728])
    
    • 腾讯云本机访问 curl -vv
    * Rebuilt URL to: https://x.x.x/
    *   Trying x.x.x.x...
    * TCP_NODELAY set
    * Connected to x.x.x (x.x.x.x) port 443 (#0)
    * ALPN, offering h2
    * ALPN, offering http/1.1
    * successfully set certificate verify locations:
    *   CAfile: /etc/ssl/certs/ca-certificates.crt
      CApath: /etc/ssl/certs
    * TLSv1.2 (OUT), TLS handshake, Client hello (1):
    * TLSv1.2 (IN), TLS handshake, Server hello (2):
    * TLSv1.2 (IN), TLS handshake, Certificate (11):
    * TLSv1.2 (IN), TLS handshake, Server key exchange (12):
    * TLSv1.2 (IN), TLS handshake, Server finished (14):
    * TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
    * TLSv1.2 (OUT), TLS change cipher, Client hello (1):
    * TLSv1.2 (OUT), TLS handshake, Finished (20):
    * TLSv1.2 (IN), TLS handshake, Finished (20):
    * SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
    * ALPN, server accepted to use h2
    * Server certificate:
    *  subject: CN=x.x
    *  start date: Jun  5 21:49:41 2019 GMT
    *  expire date: Sep  3 21:49:41 2019 GMT
    *  subjectAltName: host "x.x.x" matched cert's "*.x.x"
    *  issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
    *  SSL certificate verify ok.
    * Using HTTP2, server supports multi-use
    * Connection state changed (HTTP/2 confirmed)
    * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
    * Using Stream ID: 1 (easy handle 0x5559f69468e0)
    > GET / HTTP/2
    > Host: x.x.x
    > User-Agent: curl/7.58.0
    > Accept: */*
    
    • 外部访问 curl -vv
    * Rebuilt URL to: https://x.x.x/
    *   Trying x.x.x.x...
    * TCP_NODELAY set
    * Connected to x.x.x (x.x.x.x) port 443 (#0)
    * ALPN, offering h2
    * ALPN, offering http/1.1
    * successfully set certificate verify locations:
    *   CAfile: /etc/ssl/certs/ca-certificates.crt
      CApath: /etc/ssl/certs
    * (304) (OUT), TLS handshake, Client hello (1):
    * OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to x.x.x:443
    * stopped the pause stream!
    * Closing connection 0
    curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to x.x.x:443
    
    • frpc.ini
    [common]
    server_addr = x.x.x.x
    server_port = 7000
    token = xxxxxxx
    
    [https]
    type = https
    local_port = 666 ;
    custom_domains = x.x.x
    
    • frps.ini
    [common]
    bind_port = 7000
    vhost_https_port = 443
    vhost_http_port = 80
    token = xxxxxxx
    log_file = /var/log/frp/frps.log
    log_level = debug
    log_max_days = 3
    
    9 条回复    2019-06-27 23:31:08 +08:00
    chinesestudio
        1
    chinesestudio  
       2019-06-27 20:40:31 +08:00 via Android
    我没细想 多数端口占用 冲突咯
    chinesestudio
        2
    chinesestudio  
       2019-06-27 20:43:16 +08:00 via Android
    正确的是 nginx 监听 80 443 后端转发 你 frps 监听 443 那 https 怎么打开 443
    enng
        3
    enng  
       2019-06-27 21:04:07 +08:00 via iPhone
    最简单的是 frp 只映射 tcp 端口,然后用 nginx 做反代。
    ProjectSky
        4
    ProjectSky  
    OP
       2019-06-27 21:06:18 +08:00
    @enng 测试多次,发现好像是腾讯云把 443 端口给阻断了,所以才会出现内部通外部不通的问题。主机刚开通的时候是可以正常使用的,大概一天之后就不能使用了。
    ProjectSky
        5
    ProjectSky  
    OP
       2019-06-27 21:11:21 +08:00
    找到原因了,是域名备案的原因,没想到 443 端口也要备案了,不备案的域名走 443 或者 80 会被腾讯阻断。
    ODD10
        6
    ODD10  
       2019-06-27 21:28:22 +08:00 via iPhone
    我腾讯云 frp https 可以,https 是 nginx 服务
    ODD10
        7
    ODD10  
       2019-06-27 21:29:11 +08:00 via iPhone
    嗯,备案了的域名
    qa2080639
        8
    qa2080639  
       2019-06-27 21:59:32 +08:00
    @ProjectSky 没在腾讯云备案的域名 我这加 https 能绕过
    ProjectSky
        9
    ProjectSky  
    OP
       2019-06-27 23:31:08 +08:00
    @qa2080639
    @ODD10
    用 curl -vv https://腾讯云外网 IP 是可以得到正确返回信息的,用域名就不行了。
    找到原因就不折腾了,其实就是刚开始搞不懂相同的环境怎么就出问题了,挨个排查没想到是外部原因。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4461 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 04:04 · PVG 12:04 · LAX 21:04 · JFK 00:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.