fatedier / frp

A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.
Apache License 2.0
86.23k stars 13.34k forks source link

An option to enable TCP KeepAlived for HTTP? #2188

Closed LauTrond closed 3 years ago

LauTrond commented 3 years ago

The solution you want

Offer an option of type=http, enable TCP KeepAlived for HTTP

Alternatives considered

I found frps make every HTTP request with a single connection, even if both HTTP client and server support Connection: keep-alive Then I look into vhost/http.go, looks like the vhost disable keep-alived for all requests:

proxy := &ReverseProxy{
    ...
    Transport: &http.Transport{
        ...
        DisableKeepAlives: true

How to implement this function

Application scenarios of this function

We want FRP works faster of HTTP, don't we?

fatedier commented 3 years ago

It can't be supported now.

Go http package reuse connections by host. However, frp can route request by host and location(url path). If DisableKeepAlives is false, it will cause mistakes.

Leave this issue open here and we can consider how to achieve it later.

LauTrond commented 3 years ago

It can't be supported now.

Go http package reuse connections by host. However, frp can route request by host and location(url path). If DisableKeepAlives is false, it will cause mistakes.

Leave this issue open here and we can consider how to achieve it later.

Thanks. Sounds like we need multiple *ReverseProxy for multiple destination?

fatedier commented 3 years ago

@LauTrond I have submited a PR https://github.com/fatedier/frp/pull/2199 about to fix this issue, you can try it now and help find if it has bug.