invidious icon indicating copy to clipboard operation
invidious copied to clipboard

Allow to use proxies (HTTP(s) & socks)

Open dimqua opened this issue 5 years ago • 10 comments

This could be useful for those having a self-hosted instance. The idea is about adding an option to specify a proxy server (e.g. tor socks proxy), which can be used when a server are going to make a request to YouTube to fetch the data.

dimqua avatar Jan 19 '19 23:01 dimqua

Maybe it is also possible to proxy the youtube media through the server itself so that the users ip address is hidden to google. If this will be done, maybe also add the option to enable/disable this feature, because some hosters have traffic limit on their servers.

Perflyst avatar Jan 21 '19 08:01 Perflyst

I honestly thought this is what invidious does. I was a bit surprised that it still connects me directly to youtube. This should definitely be possible, at least with self-hosting.

Nutomic avatar Mar 07 '19 23:03 Nutomic

To be clear, the instance itself proxies requests, and then uses a proxy in another region as necessary to circumvent geo-restrictions (see #92). See my comment here for some clarification on what Invidious does.

There appears to be a socks shard that should make this possible, I'll have to look more into it to ensure it can be used here.

omarroth avatar Apr 17 '19 13:04 omarroth

Running the invidious binary with torsocks should proxy requests through Tor.

leonklingele avatar Aug 05 '19 08:08 leonklingele

I wish I could have replied to this earlier but our microsoft overlords decided they don't like my ISP.

torsocks overwrites calls to libc functions. Therefore it only works if your software is using libc. I believe the crystal network library is not implemented on top if libc, but I haven't tested nor do I know crystal. Source on that information (second and third paragraphs): https://gitweb.torproject.org/torsocks.git/tree/README.md

If this information is correct, the best way to tunnel the requests of your local instance through tor would be to either:

  1. Run it on a VM an route all the VM's traffic through tor;
  2. Run invidious under a dedicated user and use iptables to redirect every package from that user through a transparent proxy. In that case you have to make sure that your system is not using your ISP's DNS servers.

rakamanja avatar Mar 02 '20 18:03 rakamanja

It seems this issue has not received much attention. I would like to explore using the sox shard, previously called "socks". My main worry with implementing this is that Google generally does not like IP addresses of Tor exit nodes and will either completely block these addresses or result in an endless Captcha loop.

kVxQeXZbQAufBnQqA avatar Feb 13 '21 01:02 kVxQeXZbQAufBnQqA

as a private self-hoster of an instance I would love to run the requests to youtube/google also via a socks proxy. Would be awesome!

Bump, it's very cool idea and would make configuring VPN to access youtube on server-side easy to do.

JuniorJPDJ avatar Aug 06 '21 23:08 JuniorJPDJ

This issue has been automatically marked as stale and will be closed in 30 days because it has not had recent activity and is much likely outdated. If you think this issue is still relevant and applicable, you just have to post a comment and it will be unmarked.

github-actions[bot] avatar Aug 07 '22 12:08 github-actions[bot]

Is it possible to proxy requests to YouTube by connecting to tor, then connect to privoxy?

Maybe using this container (https://hub.docker.com/r/dockage/tor-privoxy#!) And having the invidious container depend on this one

pickinanameainteasy avatar Aug 07 '22 13:08 pickinanameainteasy

Candidate libraries:

socks

  • https://github.com/636f7374/socks.cr (latest update 2022 - under construction - seems unmaintained)
  • https://github.com/636f7374/herbal.cr (latest update 2021 - seems unmaintained)
  • https://github.com/jkthorne/sox (latest update 2020 - seems unmaintained)

http

  • https://github.com/mamantoha/http_proxy (latest update 3 weeks ago - seems maintained)
  • https://github.com/spider-gazelle/connect-proxy (latest update 2022 - seems unmaintained)
  • https://github.com/636f7374/connect.cr (latest update 2022 - seems unmaintained)
  • https://github.com/636f7374/carton.cr (latest update 2021 - seems unmaintained)

@SamantazFox I think in the lights of #3822, this issue should be our main priority to more easily bypass YouTube restrictions.

unixfox avatar Jul 10 '23 13:07 unixfox

Still a work in progress but here's HTTP proxy support through the http_proxy shard:

https://github.com/syeopite/invidious/tree/http-proxy

It works although InnerTube requests aren't proxied for some reason but /videoplayback and related endpoints are. Still, this should allow us to bypass YouTube's blockage more easily seeing as they're mostly restricting access to the streaming urls.

To use just set at least the host and port configuration here.

##
## Configuration for using a HTTP proxy
##
## If unset, then no HTTP proxy will be used.
## 
http_proxy:
  user:
  password:
  host:
  port:

I haven't tested every edge case but it seems to be stable.

syeopite avatar Aug 26 '23 01:08 syeopite

@syeopite very good, I think that was a big missing piece in the puzzle for trying to solve the geo-restrictions: https://github.com/iv-org/invidious/issues/92

unixfox avatar Aug 27 '23 22:08 unixfox

Can we make it so it uses the https_proxy env var passed to the docker image? Also you may want to update INVIDIOUS_CONFIG in docker-compose.yml. Edit: Also if I remove the user and password config line, I get an error Unhandled exception: Couldn't parse (HTTPProxyConfig | Nil) at line 14, column 3 (YAML::ParseException). Maybe you could make them entirely optional?

Edit 2: I got it to work now. First time I can actually run my own invidious. Good work! 👍

mk-pmb avatar Dec 29 '23 06:12 mk-pmb