0

I am currently running apache2 on my server, but would like to forward http(s) traffic requesting a specific host (ex. lxc.example.com) to an LXC container which can be accessed by a local ip address on the box.

I have looked into iptables, however from my understanding iptables doesn't handle http(s) traffic, so as far as I can tell there are no forwarding rules based on host name I can apply.

I would prefer not to forward traffic to a specific port (ex. lxc.example.com:8080) since that makes the URL look unprofessional and requires additional port forwarding configuration.

It seems like there is probably an obvious solution I'm missing, but my searches haven't revealed anything yet. Any help would be appreciated.

1 Answers1

0

A reverse proxy is the solution.

Define a virtual host for the domain of the container that will reverse proxy the traffic. This will forward all traffic from lxc.example.com to localip. Let me know if this is not what you want.

<VirtualHost>
ServerName lxc.example.com
ProxyPass "/"  "http://localip/"
ProxyPassReverse "/"  "http://localip/"
</VirtualHost>

Disclaimer: Configuration untested.

Don't forget to restart the apache2 service.

Daniel
  • 151
  • 1
  • 6