I use Caddy to forward HTTP/HTTPS traffic to containers. I also use Gobetween to stream TCP/UDP ports to containers.
For both of Caddy & Gobetween I always get the lxdbr0 IP address to logs as Public IP.
What’s the proper way to get Public IP for containers’ applications: Apache HTTP, Nginx, Caddy, OpenVPN etc.
And I also tried to run iptables for NAT. But cannot see the NAT at iptables rules list:
[23:21:39@9] [root@lxd:~]# iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 587 -j DNAT --to-destination 100.66.2.161:80 [23:25:26@9] [root@lxd:~]# iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT tcp -- anywhere anywhere tcp dpt:domain /* generated for LXD network lxdbr0 */ ACCEPT udp -- anywhere anywhere udp dpt:domain /* generated for LXD network lxdbr0 */ ACCEPT udp -- anywhere anywhere udp dpt:bootps /* generated for LXD network lxdbr0 */ Chain FORWARD (policy ACCEPT) target prot opt source destination ACCEPT all -- anywhere anywhere /* generated for LXD network lxdbr0 */ ACCEPT all -- anywhere anywhere /* generated for LXD network lxdbr0 */ Chain OUTPUT (policy ACCEPT) target prot opt source destination ACCEPT tcp -- anywhere anywhere tcp spt:domain /* generated for LXD network lxdbr0 */ ACCEPT udp -- anywhere anywhere udp spt:domain /* generated for LXD network lxdbr0 */ ACCEPT udp -- anywhere anywhere udp spt:bootps /* generated for LXD network lxdbr0 */
Caddyfile:
subdomain.example.com { proxy / rubyonrails.lxd:9292 { transparent } gzip }
Gobetween:
[servers.rubyonrails] protocol = "tcp" bind = "0.0.0.0:9292" [servers.rubyonrails.discovery] kind = "static" static_list = [ "rubyonrails.lxd:9292" ]
LXD version: 2.17
OS: Ubuntu 16.04
eth0: 10.5.138.205
lxdbr0: 100.66.2.1