ProjectSky
V2EX  ›  问与答

有用 frp 的吗,请教个问题

  •  
  •   ProjectSky · Jun 27, 2019 · 4574 views
    This topic created in 2539 days ago, the information mentioned may be changed or developed.

    这两天被这个 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 replies    2019-06-27 23:31:08 +08:00
    chinesestudio
        1
    chinesestudio  
       Jun 27, 2019 via Android
    我没细想 多数端口占用 冲突咯
    chinesestudio
        2
    chinesestudio  
       Jun 27, 2019 via Android
    正确的是 nginx 监听 80 443 后端转发 你 frps 监听 443 那 https 怎么打开 443
    enng
        3
    enng  
       Jun 27, 2019 via iPhone
    最简单的是 frp 只映射 tcp 端口,然后用 nginx 做反代。
    ProjectSky
        4
    ProjectSky  
    OP
       Jun 27, 2019
    @enng 测试多次,发现好像是腾讯云把 443 端口给阻断了,所以才会出现内部通外部不通的问题。主机刚开通的时候是可以正常使用的,大概一天之后就不能使用了。
    ProjectSky
        5
    ProjectSky  
    OP
       Jun 27, 2019
    找到原因了,是域名备案的原因,没想到 443 端口也要备案了,不备案的域名走 443 或者 80 会被腾讯阻断。
    uTOmOuk3L6sb4MSI
        6
    uTOmOuk3L6sb4MSI  
       Jun 27, 2019 via iPhone
    我腾讯云 frp https 可以,https 是 nginx 服务
    uTOmOuk3L6sb4MSI
        7
    uTOmOuk3L6sb4MSI  
       Jun 27, 2019 via iPhone
    嗯,备案了的域名
    qa2080639
        8
    qa2080639  
       Jun 27, 2019
    @ProjectSky 没在腾讯云备案的域名 我这加 https 能绕过
    ProjectSky
        9
    ProjectSky  
    OP
       Jun 27, 2019
    @qa2080639
    @ODD10
    用 curl -vv https://腾讯云外网 IP 是可以得到正确返回信息的,用域名就不行了。
    找到原因就不折腾了,其实就是刚开始搞不懂相同的环境怎么就出问题了,挨个排查没想到是外部原因。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1662 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 16:38 · PVG 00:38 · LAX 09:38 · JFK 12:38
    ♥ Do have faith in what you're doing.