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

https+wss proxy #13

Open
xenion54 opened this issue Oct 25, 2024 · 2 comments
Open

https+wss proxy #13

xenion54 opened this issue Oct 25, 2024 · 2 comments

Comments

@xenion54
Copy link

xenion54 commented Oct 25, 2024

Hi @walkor. In my project, i'm using this awesome example of http proxy server. And its work fine. Btw its work for http+websocket proxy.
But when i try to use it with https and wss its fail.
I see, that this is because in method "onMessage" i have encrypted data. Can you pls help me to solve this task?

Of cource, when i do this

$remote_connection->pipe($connection); 
$connection->pipe($remote_connection);
$remote_connection->connect();

data passing encrypted to destination and its not what he expects.

I try to replace tcp://0.0.0.0:xxx to http://0.0.0.0:xxx, but it still not working. Pls, help me.

Here is my minimal code, for reproduce

<?php

$context = array(
    'ssl' => array(
        'local_cert' => app_paths['ssl_public_key'], // Alternatively, it can be a crt file
        'local_pk' => app_paths['ssl_private_key'],
        'verify_peer' => false,
        'allow_self_signed' => true,
    )
);

$worker = new Worker('tcp://0.0.0.0:' . $args['port'], $context);
$worker->transport = 'ssl';

$worker->onMessage = function ($connection, $buffer) use ($args) {

    list($method, $addr, $http_version) = explode(' ', $buffer);
    $remote_connection = new AsyncTcpConnection("tcp://{$args['proxy-ip']}:{$args['port']}");
    if ($method !== 'CONNECT') {
        $remote_connection->send($buffer);
    } else {
        $connection->send("HTTP/1.1 200 Connection Established\r\n\r\n");
    }
    $remote_connection->pipe($connection);
    $connection->pipe($remote_connection);
    $remote_connection->connect();

};
@walkor
Copy link
Owner

walkor commented Oct 28, 2024

This project supports HTTPS and WSS without the need to modify the source code.

@xenion54
Copy link
Author

xenion54 commented Nov 9, 2024

Yes, supports. Just in $buffer variable inside onMessage callback, i have encrypted data in this example. When i disable https, buffer filled not encrypted data.
i resolve my problem using nginx proxy for establish https connection. But still want to know what i m doing wrong.

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

No branches or pull requests

2 participants