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

HTTPClient not support HTTP/HTTPS proxy #4269

Open
2 tasks done
HADB opened this issue Jun 24, 2024 · 5 comments · May be fixed by #4270
Open
2 tasks done

HTTPClient not support HTTP/HTTPS proxy #4269

HADB opened this issue Jun 24, 2024 · 5 comments · May be fixed by #4270
Assignees
Labels
self-hosting Anything self-hosted

Comments

@HADB
Copy link

HADB commented Jun 24, 2024

Past Issues Searched

  • I have searched open and closed issues to make sure that the bug has not yet been reported

Issue is a Bug Report

  • This is a bug report and not a feature request, nor asking for self-hosted support

Using official Plausible Cloud hosting or self-hosting?

Self-hosting

Describe the bug

First of all, thank you for the great work on this project!

Currently, the HTTPClient seems not support using HTTP or HTTPS proxies set via environment variables (HTTP_PROXY and HTTPS_PROXY). This functionality is important for users who need to route traffic through a proxy for various reasons, such as network restrictions or privacy concerns.

In my case, I'm facing network restrictions while connecting to Google services or Gravartor avatars.

Expected behavior

The HTTPClient should respect the HTTP_PROXY / HTTPS_PROXY environment variables and route HTTP/HTTPS requests through the specified proxy.

Screenshots

No response

Environment

No response

@ruslandoga
Copy link
Contributor

ruslandoga commented Jun 24, 2024

👋 @HADB

Where do the HTTP_PROXY and HTTPS_PROXY environment variables come from? Have they been documented somewhere?
I don't think we have them anywhere in the code base.

@ruslandoga ruslandoga added the self-hosting Anything self-hosted label Jun 24, 2024
@ruslandoga ruslandoga self-assigned this Jun 24, 2024
@HADB
Copy link
Author

HADB commented Jun 24, 2024

@ruslandoga Hi, thanks for replying. HTTP_PROXY and HTTPS_PROXY are environment variables used to specify proxy servers for HTTP and HTTPS traffic respectively. Many applications and libraries recognize and use these variables to route their network traffic through specified proxy servers, such as:curl, wget and Python’s requests library.

@ruslandoga
Copy link
Contributor

ruslandoga commented Jun 24, 2024

I see. We might be able to provide support for these env vars later, but for now we can at least make proxying configurable via custom config files. I'll open a PR for that later today with an example configuration.

@ruslandoga ruslandoga linked a pull request Jun 24, 2024 that will close this issue
4 tasks
@ruslandoga
Copy link
Contributor

ruslandoga commented Jun 24, 2024

@HADB would you be able to try out the image I built from #4270?

Here're the changes you'd need to make:

docker-compose.yml

plausible:
- image: ghcr.io/plausible/community-edition:v2.1.1
+ image: ghcr.io/ruslandoga/plausible:build-allow-finch-config-9456444
+ volumes:
+   - ./my_config.exs:/app/my_config.exs

my_config.exs

import Config

# Plausible uses HTTPS for all outgoing requests, and our HTTP client (Mint) doesn't support HTTPS->HTTPS proxying
# https://hexdocs.pm/mint/Mint.HTTP.html#connect/4-proxying recommends HTTP->HTTPS in this case
config :plausible, Plausible.Finch, conn_opts: [proxy: {:http, _host = "some.proxy.com", _port = 1080, _opts = []}]

Note that you would need to provide your own proxy host/port pair. There is also an example config in #4270 where host and port are extracted from HTTP_PROXY env var.

plausible-conf.env

+ EXTRA_CONFIG_PATH=/app/my_config.exs

@HADB
Copy link
Author

HADB commented Jun 27, 2024

@ruslandoga I have tried this image and it works as expected! Great job! Thanks a lot!

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

Successfully merging a pull request may close this issue.

2 participants