DNS resolution through a proxy
Solution 1
How can I make wget or even git use the proxy instead of a direct DNS query?
Set the proxy environment variable and it will do this straight up:
export http_proxy='http://proxy.contoso.com:3128/'
wget http://www.example.net/
Solution 2
there is no mechanism to specify that the proxy should try a particular IP address for a particular host. You could change the URL from, say, http://example.com/mypage to http://33.33.33.33/mypage, but then the proxy server won't know the hostname to request. The modern web (HTTP/1.1) depends on a Host header always being present in a request, allowing one web server to serve multiple sites identified by their hostname.
Your best bet would be to configure the proxy server to use the DNS resolver of your choice. This would only be possible if you use a local proxy server that you control.
Related videos on Youtube
nowox
Software and Electronic Engineer specialized in MotionControl applications.
Updated on September 18, 2022Comments
-
nowox over 1 year
I am behind a very capricious proxy (squid) and it seems only http requests made with a particular user-agent are allowed.
When fetching
google.com
from Google Chrome, I can see aHTTP GET
on WireSharc. However,wget
tries to resolve the DNS first through the default DNS servers which never answer.How can I make
wget
or evengit
use the proxy instead of a direct DNS query?-
roaima about 8 yearsIf you're seeing that DNS requests are never answered, why do you think it's the fault of the proxy? Please edit your question to clarify.
-
nowox about 8 years@roaima I never said it is the proxy's fault. I said wget is not doing the name resolution through the proxy.
-
roaima about 8 yearsPlease could you clarify the relevance of "it seems only http requests made with a particular user-agent are allowed" to the DNS lookup issue you're describing. I don't see the connection. Thanks.
-
Adrien almost 8 yearsif wget is still doing a DNS lookup for the target site (not the proxy) then it's not set to use a proxy. You could resolve the lookup problem with a hosts file entry, but that will just push the problem to the next stage, if it doesn't make a proper proxy request to the proxy, it will be rejected then.
-
-
nowox about 8 yearsI already did it. From chrome I get a
HTTP REQUEST
and fromwget
I still get aTCP
request to theDNS
. So Chrome is just asking the proxy andwget
tries to resolve the DNS first. -
nowox about 8 yearsSo how is it possible that Chrome does not make a query to the DNS itself?
-
roaima about 8 years@nowox I don't get any DNS lookup from
wget
in this configuration. What platform (OS) are you using?