Skip to content

CONNECT and HTTP Proxy #1676

Open
Open

Description

@Napolitain

I tried to setup a server with .connect("/") endpoint, to support HTTPS proxy. I dont think it works at all though, and I'm not even sure that method in the library is supposed to do that.

I'm building an app that requires capturing CONNECT event, so I'm curious to know if there is an easy enough way (in other words, having an api on HTTP level).

Because of the passthrough nature of the server, it is particularly important to have high performance, so I'm inclined to choose uWebSockets.

Here's my starting point :

   auto app = uWS::App({
        "",
        "",
    }).connect("/", [](auto *res, auto *req) {
        // When a client connects to the HTTP proxy server. It should answer 200 OK.
        LOG(INFO) << "CONNECT";
        res->writeStatus("200 OK")->end();
    }).get("/", [](auto *res, auto *req) {
        // When a client connects to the HTTP proxy server. It should answer 200 OK.
        LOG(INFO) << "GET";
        res->writeStatus("200 OK")->end("Hello World!");
});

Get on localhost:8080 logs GET, get on google with HTTP/HTTPS proxy set to localhost:8080 doesnt log CONNECT (though, it does sends CONNECT according to Wireshark).

Is this feature lacking ? Or is it simply too high level of a library (I know CONNECT is a bit inbetween HTTP and plain TCP connection)

Thanks for clarifying

Activity

  1. uNetworkingAB commented on Nov 23, 2023

    @uNetworkingAB
    Contributor

    https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/CONNECT

    That's probably a lack in the Http router, we probably only support simple URLs, not "www.example.com:443" kind of lines.

    We could definitely make the router more generic, but I think you will have better luck with a proper proxy project instead of uWS. Proxying is not really a considered case for uWS. We don't even have client support, at all.

  2. uNetworkingAB commented on Nov 23, 2023

    @uNetworkingAB
    Contributor

    I marked this as out of scope, but the Http router fix itself is probably in-scope. So we can keep this issue open. Http router needs a rewrite at some point anyways.

  3. uNetworkingAB commented on Jan 30, 2024

    @uNetworkingAB
    Contributor

    Do people expect something like this:

    GET https://google.com/test/yes

    to be matching with app.get("/test/yes", ..)

    and have something like req.getBaseURL() to return "https://google.com"

    ? Or how does Express do it?

  4. uNetworkingAB commented on Jan 30, 2024

    @uNetworkingAB
    Contributor

    probably better to use parameter routes to catch the domain like so:

    app.get("/:domain/test/yes", ..)

    or

    app.get("/:domain/*", ..) and use req.getWildcard() for the local URL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions