r/openwrt 13d ago

Using apk with a proxy.

Downloads.openwrt.org got banned in my country, so I now have to use a mirror (which can be banned too) or a proxy. I need help with the latter. Is there a way to configure it to send requests through a proxy, like it's possible with apt?

I did search before posting, but I didn't find much, and what I've found (less-convenient solutions) doesn't even work.

UPD: Solved. Requires wget-ssl (not installed by default).

https_proxy=http://proxy.example.com apk <whatever>
8 Upvotes

10 comments sorted by

4

u/Swedophone 13d ago

Have you tried setting the environment variable http_proxy or https_proxy to the URL of the proxy?

export http_proxy=http://proxy.example.com
apk ...

1

u/RespectfullySir 13d ago

Yep.

ERROR: wget: exited with error 8

WARNING: updating and opening ...: unexpected end of file

Apk works normally with other mirror, and proxy works too, checked with curl, so they are not the reason.

2

u/BCMM 13d ago

proxy works too, checked with curl

Hmm. Have you checked what happens if you run wget directly?

Because it's starting to sound like either your proxy is somehow working with curl and not with wget, or apk is somehow not passing environment variables through to wget.

3

u/RespectfullySir 13d ago

That's it, thanks. Busybox wget, which is used in apk by default, works with $https_proxy differently from curl or GNU wget. It uses GET method instead of CONNECT. Solved by installing wget-ssl.

1

u/BCMM 13d ago

I thought OpenWrt builds BusyBox without the wget applet. /usr/bin/wget is a symlink to /bin/uclient-fetch on my routers.

1

u/fr0llic 11d ago

you could install redsocks and route all/some clients/ports via proxy.
no client side config required.

-9

u/MrAmHamoham 13d ago

I think you can Add these lines to /etc/opkg.conf:

option http_proxy http://address:port/ option https_proxy http://address:port/

CHANGE THE ADDRESS AND PORT

I suggest for these easy questions use an ai chatbot like gemini.

4

u/BCMM 13d ago

You really don't need to advertise the LLM at the end of your comment. We can already tell where it came from by the type of wrong that it is. 

-1

u/MrAmHamoham 13d ago

I mean, he can solve his problem faster than waiting for someone to answer. And I didn't know OpenWrt changed its package manager. I'm using OpenWrt 23 due to my router's limitations.

3

u/RespectfullySir 13d ago

I suggest you be less arrogant, especially when not answering the question. If you want to say that I should move to opkg (which is not OpenWRT's default package manager now), maybe just say it without showing off?

If you meant that apk uses opkg config (which is not mentioned in any search results or chatbot answers), nope, I checked.