Skip to content

Proxy support for outgoing http request - #214

Open
ArnaultMICHEL wants to merge 5 commits into
ltb-project:masterfrom
ArnaultMICHEL:proxy_support
Open

Proxy support for outgoing http request #214
ArnaultMICHEL wants to merge 5 commits into
ltb-project:masterfrom
ArnaultMICHEL:proxy_support

Conversation

@ArnaultMICHEL

Copy link
Copy Markdown

See description in ticket #213

Comment thread htdocs/geocode.php Outdated
);

if ($use_proxy) {
$http_settings['proxy'] = "tcp://" . $proxy_host . ":" . $proxy_port;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

using tcp:// seems too restrictive here. Could you add a variable $proxy_protocol?

Also, please test if proxy_port is set before adding ":" . $proxy_port

@ArnaultMICHEL ArnaultMICHEL Feb 11, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for your code review.

Adding isset() test to both variables is a very good practice 👍

PHP official documentation for stream-context-create leads to HTTP context options. It's not crystal clear to me if we can use another scheme.

So I tested it with a local squid :

  • in htdocs/geocode.php, when replacing tcp:// by http://, it doesn't work and throw the following error
[Wed Feb 11 21:33:21.771370 2026] [php:notice] [pid 335:tid 335] [client X.X.X.X:36754] PHP Parse error:  syntax error, unexpected token "and" in /var/www/htdocs/geocode.php on line 33, referer: http://X.X.X.X:8080/index.php?page=map
  • while a simple curl test using https_proxy env var is OK : $ https_proxy="http://mysquidproxy.local:3128" curl https://google.fr -v -4

I therefore suggest keeping tcp:// hardcoded, as the library does not appear to support other protocol schemes.

I would be happy to modify it if you find a counter-example.

Comment thread htdocs/geocode.php Outdated
if ($use_proxy) {
$http_settings['proxy'] = "tcp://" . $proxy_host . ":" . $proxy_port;
if ($proxy_use_ssl) {
$http_settings['request_fulluri'] = true;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This has nothing to do with ssl, right? We may enable this option, but I recommend renaming it into $proxy_request_fulluri

Anyway, for ssl proxy options, I suggest using the 'ssl' key of http_settings, and having an array $proxy_ssl_options in configuration for storing the complete ssl options. A commented example of such configuration could be set in config.inc.php.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

OK, sounds good to me. I will propose that

Comment thread htdocs/geocode.php Outdated
if ($proxy_use_ssl) {
$http_settings['request_fulluri'] = true;
}
if ($proxy_auth) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think we should rename $proxy_auth into $proxy_auth_authorization_method, as there are multiple authentication schemes. The values could be: "none" (default) and "basic".

@ArnaultMICHEL ArnaultMICHEL Feb 11, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Generally speaking, authorization are checked on the server side, after authentication.
In our use case, we are providing credentials for authentication on the proxy.
So i would propose $proxy_authentication_method

You are absolutely right, an HTTP proxy can provide multiple authentication methods : Basic, NTLM, SPNEGO, OAuth2, ... (ref squid doc).

From my experience :

  • only few softwares like curl or browsers are supporting other authentication methods than Basic,
  • HTTP proxies dedicated to servers or workloads almost always offer basic authentication.

So i would propose $proxy_authentication_method, and only support the none and basic options to start with..

Comment thread conf/config.inc.php
$proxy_auth = false;
$proxy_auth_user = "user";
$proxy_auth_pass = "password";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The parameters seems self-explanatory here, but we should describe them in the documentation as well.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I propose an update on docs/mapmenu.rst, i hope it will fit what you expect

@ArnaultMICHEL

Copy link
Copy Markdown
Author

please note that i still need to test basic auth with squid, i'll inform you when it's validated.

@ArnaultMICHEL

Copy link
Copy Markdown
Author

Tests with squid proxy + basic auth are now done, and it's working.
I simply follow this squid config guide to configure squid.

note : tests with SSL Bump (TLS interception) could be done following this repository, but i didn't plan to cover it at this stage.

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.

2 participants