Reverse Proxy with squid

squid

Im trying to setup a reverse proxy so that i can have multiple web servers on my network.

I currently have 2 servers:

10.0.0.45 - New Server Webserver/Squid Proxy
10.0.0.40 - Old Server Webserver

i was able to make it so that all traffic on port 1234 on the new server (10.0.0.45) was sent to 80 on the old server (10.0.0.40). but im now having issues when trying to forward domains.

I want to forward like this:

*.arcath.net -> 10.0.0.40
londinium.arcath.net -> 10.0.0.45
support.ed-itsolutions.com -> 10.0.0.40

Im not too bothered if i have to manually add all the subdomains instead of *.

Can anyone give me a config example to do this?

My squid.conf looks like this:

http_port 1234 defaultsite=10.0.0.45:80
cache_peer 10.0.0.40 parent 80 0 no-query originserver name=whitefall
cache_peer_domain whitefall www.arcath.net blog.arcath.net .arcath.net
cache_peer 10.0.0.45 parent 80 0 no-query originserver name=londinium
cache_peer_domain londinium londinium.arcath.net

acl all src 0.0.0.0/0.0.0.0
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443          # https
acl SSL_ports port 563          # snews
acl SSL_ports port 873          # rsync
acl Safe_ports port 80          # http
acl Safe_ports port 21          # ftp
acl Safe_ports port 443         # https
acl Safe_ports port 70          # gopher
acl Safe_ports port 210         # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280         # http-mgmt
acl Safe_ports port 488         # gss-http
acl Safe_ports port 591         # filemaker
acl Safe_ports port 777         # multiling http
acl Safe_ports port 631         # cups
acl Safe_ports port 873         # rsync
acl Safe_ports port 901         # SWAT
acl web dstdomain 10.0.0.40
acl purge method PURGE
acl CONNECT method CONNECT

http_access allow all
http_access allow localhost

At the moment all domains end up going to 10.0.0.45

Best Answer

The following contains an example of what you try to achieve: http://wiki.squid-cache.org/ConfigExamples/Reverse/MultipleWebservers

Please try your above configuration changing the defaultsite instruction to

http_port 1234 defaultsite=londinium.arcath.net

According to the squid documentation

defaultsite=domainname
        What to use for the Host: header if it is not present
        in a request. Determines what site (not origin server)
        accelerators should consider the default.
        Implies accel.
Related Topic