Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Support h2c in vhost server #4563

Open
11 tasks
sword-jin opened this issue Nov 28, 2024 · 4 comments · May be fixed by #4561
Open
11 tasks

[Feature Request] Support h2c in vhost server #4563

sword-jin opened this issue Nov 28, 2024 · 4 comments · May be fixed by #4561

Comments

@sword-jin
Copy link

Describe the feature request

Like the title, we can enable h2c support in vhost server, there is a PR already

#4561

Describe alternatives you've considered

No response

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others
@sword-jin
Copy link
Author

@fatedier I think it's safe to wrapper the handler with h2c if we don't want to introduce new optional parameter

@fatedier
Copy link
Owner

Could you provide relevant documentation or examples from other projects? Also, please add an end-to-end (e2e) test case to ensure existing functionality is not affected.

@sword-jin
Copy link
Author

I see, I will write a e2e test case, I think we can see the real user case in the e2e case

@sword-jin
Copy link
Author

sword-jin commented Nov 29, 2024

I can't reprocude the bug when running all the components locally, this is my playground https://github.com/sword-jin/caddy-frp-grpc-streaming/blob/be0c28f7a1a0972a6103b8434d43f73ea51f9939/cmd/client/main.go#L46

sequenceDiagram
    autonumber
    actor B as Browser
    box Purple On Cloud
    participant C as Caddy
    participant FS as Frps
    end
    box Grey On Local
    participant FC as Frpc
    participant LS as LocalServer
    end
    
    B ->> C: request 443
    C ->> C: tls termination
    C ->> FS: reverse proxy to 8888
    FS ->>+ FC: notify the client new connection
    FC ->>- FS: new tcp connection
    FS ->> FC: forward request
    FC ->> LocalServer: forward request
Loading

This diagram Illuminates how a request reach out the local server. This repo trys to build the same worfklow, but fortunately it doesn't work.

In the playground, we use a mock certificate, and the client skip the validation

When the frps and caddy on real cloud with a real tls certificate, the client always gets stream error: internal: protocol error: no Grpc-Status trailer: unexpected EOF at https://github.com/sword-jin/caddy-frp-grpc-streaming/blob/be0c28f7a1a0972a6103b8434d43f73ea51f9939/cmd/client/main.go#L46-L48

Form the logs of caddy and frps and local server, the request has been handled successfully, the problem is the trailer header is missing.

What I did to fix is add a h2c layer in frp vhost server and use http2 transport

I check the frps's response, left is without h2c, right is with h2c, the difference is left doesn't have Trailer:Grpc-Status which cause the error

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants