0

When I modify local hosts file so that:

1.1.1.1 example.com

and connect to example.com using my browser, everything works fine (it requests "example.com" Host: on 1.1.1.1 server)

but when I try to connect through proxy, it ignores it and tries to resolve example.com through proxy (when I put that line in /etc/hosts on the server, it works fine).

I tried to use HTTP Header Modifier addon in Chrome but it works the same.

How to change requested Host on a local machine while connecting through proxy? (I'm fine with editing squid.conf, I just don't want to SSH to the server each time I have a new domain).

1 Answer 1

0

You're asking for the impossible. The machine running the proxy server is where the name→address lookup (to find the HTTP content server) is done, when you use an HTTP proxy server (as you want to). So the machine running the proxy server is where you have to add lookup overrides such as your example.com1.1.1.1. If you want that to be your own machine, then you'll have to run the HTTP proxy server on your own machine.

Of course, you could set up some Rube Goldberg mechanism where the machine with your proxy server uses a proxy DNS server on a machine somewhere else, and the machine with the proxy DNS server has the lookup overrides. But all that that will have given you is (a) an extra external dependency for your HTTP proxy server machine, (b) a different machine that you still have to SSH into and edit data files on when you want to add another lookup override, and (c) possible severe adverse effects on other services on that server machine such as mail, news, FTP, LAN user authentication, and so forth because DNS lookup overrides apply to more than just HTTP.

(I'm not going to touch upon even more arcane mechanisms such as sending mail to a [email protected] mailbox on the server whose ~alias/.qmail-squid file invokes a bespoke program that parses the mail for edit commands that are then applied through ex to squid.conf et al.. Because I'd then have to cover the extensive security ramifications of allowing the whole of Internet at whim to edit your server's configuration by mail. It would be vastly silly to set up such a system solely because one didn't want to expend the comparatively tiny effort of using ssh.)

You're going to have to live with the fact that making an HTTP proxy server do this particular task requires you to do server administration, of one kind or another, on the machine running the server, whichever machine that turns out to be.

2
  • I don't think it's impossible. Basically what I'm trying to do: from a local computer tell squid to connect to 53.25.23.266 and make 'Host:' header "example.com". The machine with squid doesn't need to resolve anything. The user of local computer is aware of the situation and can cooperate; I just don't want him/her to modify /etc/hosts on the server.
    – Matt
    Jan 18, 2014 at 13:45
  • Nonsense. The machine with squid has to resolve example.com to that IP address. To make it do that, one has to do server administration on the squid machine. It doesn't happen by magic all by itself.
    – JdeBP
    Jan 24, 2014 at 1:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .