0

I have installed 5 LXC containers in Proxmox. Each container has a Apache2 webserver up and running inside, pointing to a registered domain.

So:
container1 points to example1.com and has a local ip address of 192.168.2.225
container2 points to example2.com and has a local ip address of 192.168.2.230
container3 points to example3.com and has a local ip address of 192.168.2.235
and so on.

I would like to forward requests for the 5 different domains to the according container. All containers have static ip's and are bridged on vmbr0 to the physical NIC (enp3s0)

So I tried to achieve it with a separate container, running Squid proxy,with a local ip address of 192.168.2.253 and port 3128, which is Squid's default listening port.

First I had setup iptables on the Proxmox host with the following rules:

iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 22 -j DNAT --to 192.168.2.253:3128
iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 80 -j DNAT --to 192.168.2.253:3128
iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 443 -j DNAT --to 192.168.2.253:3128
iptables --t nat -A POSTROUTING --out-interface vmbr0 -j MASQUERADE

After that I tried to configure Squid:

http_port 3128
http_access allow all
http_port 3128 intercept
visible_hostname squid.proxy


acl 100 dstdomain .example1.com
acl 101 dstdomain .example2.com
acl 102 dstdomain .example3.com

cache_peer 192.168.2.225 parent 80 0 no-query
cache_peer 192.168.2.230 parent 80 0 no-query
cache_peer 192.168.2.235 parent 80 0 no-query

When browsing to example1.com, I am notified by Squid with the message:

The requested URL could not be retrieved

My question is: what can I do to forward each domain successfully to it's according container?

kzpm
  • 99
  • 1
  • 9
  • 1
    Does this answer your question? [What is a Reverse Proxy?](https://serverfault.com/questions/8654/what-is-a-reverse-proxy) – vidarlo May 28 '23 at 07:58
  • i would just suggest, that you dont use nat, but nginx on the host as i do and forward via reverse proxy function to the hosts geneerell a nat is still required imho – djdomi May 28 '23 at 16:47

0 Answers0