Skip to content

Support for HTTP CONNECT Proxies#1396

Open
DIDONAX wants to merge 5 commits into
motis-project:masterfrom
DIDONAX:connect-method
Open

Support for HTTP CONNECT Proxies#1396
DIDONAX wants to merge 5 commits into
motis-project:masterfrom
DIDONAX:connect-method

Conversation

@DIDONAX

@DIDONAX DIDONAX commented May 9, 2026

Copy link
Copy Markdown
Contributor

@DIDONAX

DIDONAX commented May 9, 2026

Copy link
Copy Markdown
Contributor Author
  • @felixguendling i am not so sure of this one: removed use_tls flag from proxy struct, the flag was intended to support client-proxy encryption, but from what i read its not common especially in conjunction with connect, and if it exists i assume its used to hide Proxy-Authorization headers which we don't currently support. What do you think ?
  • also proxy is only used for gbfs updates i think we should consider adding it to the other ep as well.

@DIDONAX
DIDONAX requested a review from felixguendling May 9, 2026 12:31
@traines-source

Copy link
Copy Markdown
Contributor

also proxy is only used for gbfs updates i think we should consider adding it to the other ep as well.

As long as it is configurable separately. For Transitous we rely on setting a proxy for GBFS but not for GTFS-RT feeds.

Comment thread src/http_req.cc
auto const use_tls =
proxy.has_value() ? proxy->use_tls_
: next_url.scheme_id() == boost::urls::scheme::https;
auto const use_tls = next_url.scheme_id() == boost::urls::scheme::https;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will kill support for non-CONNECT proxies?
we still want to support "normal" proxies

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump @DIDONAX

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i tested this with proxy=https://rt.triptix.tech and use_connect = false and it works.

Comment thread include/motis/http_req.h Outdated
boost::asio::awaitable<void> http_CONNECT(Stream& stream,
boost::urls::url const& url,
std::optional<proxy> const& proxy) {
if (!proxy) co_return;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always use braces

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump @DIDONAX

@felixguendling felixguendling changed the title implement connect + bug fixes Support for HTTP CONNECT Proxies May 29, 2026
Comment thread src/http_req.cc Outdated
Comment on lines -147 to -149
auto const use_tls =
proxy ? proxy->use_tls_
: next_url.scheme_id() == boost::urls::scheme::https;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't we need this anymore?

@DIDONAX DIDONAX Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was wrong, the request schema should always be that of the target: for example before for an http proxy a http request will always be forwarded even for an https target. i used mitmproxy to confirm this .

this is before (master branch) the feed endpoint is never reached:
image

and after:
image

so basically it wasn't working before when proxy and target schema didnt match.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For CONNECT yes, but also for non-CONNECT? If the proxy is https but the target is http, I still need to send a https request?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also depends on the config of the proxy I guess. In rt.triptix.tech the schema of the target is just hardcoded, in a dynamic proxy I'm not sure what is supposed to happen. But maybe I'm missing something. I think rt.triptix.tech might not handle redirects correctly in this case either.

@DIDONAX DIDONAX Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the screenshots are with use_connect=false so this is the normal case. i also tested rt.triptix.tech with connect disabled and it seems to work. can you test if this is also the case for you?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with rt.triptix.tech actually both variants should work because it listens on both 80 and 443 and because it will contact the upstream target with whatever scheme was configured for that target in the proxy.
But I guess in the end you're right that for a dynamic proxy, it is most important to know whether to connect to the upstream via http or https and without any additional headers etc it can only know that from it's own connection to the client – meaning all such proxies would need to listen on both http and https.

Do we know about someone else using the proxy feature already?

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 this pull request may close these issues.

Use HTTP CONNECT method for proxy server

3 participants