[squid-users] Overwrite an URL containing an IP when it is requested with a custom Host header
Alex Rousskov
rousskov at measurement-factory.com
Wed Oct 16 18:20:30 UTC 2019
On 10/16/19 1:12 PM, jl wrote:
> It's possible to configure Squid to overwrite an URL containing an IP when
> it is requested with a custom Host header passed by the client when the Host
> header resolves to the IP in the URL?
You can probably accomplish the above using a URL rewriting helper or an
adaptation service. Those things can receive requested headers, do DNS
lookups, and rewrite URLs as needed.
If the IP and host values can be hard-coded into Squid configuration,
then it might be possible to accomplish what you want using Squid
configuration alone (e.g., via a dedicated cache_peer originserver
setting), but I am not sure.
Alex.
> For example for this:
> curl -v -k -x IP:PORT http://34.201.191.134/headers -H "Host: httpbin.org"
>
> to return:
>
> "headers": {
> "Accept": "*/*",
> "Host": "httpbin.org",
> "User-Agent": "curl/7.58.0"
> }
>
> instead of:
>
> "headers": {
> "Accept": "*/*",
> "Host": "34.201.191.134",
> "If-Modified-Since": "Wed, 16 Oct 2019 16:08:42 GMT",
> "User-Agent": "curl/7.58.0"
> }
>
> Or for this:
> curl -v -k -x IP:PORT http://192.121.151.106/doc/search/ -H "Host:
> erlang.org"
>
> to return "HTTP/1.1 200 OK" instead of "HTTP/1.1 404 Not Found"
More information about the squid-users
mailing list