<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'>
<p>Hi there,</p>
<p>I've some problems with connecting to my containers via my public domain from the host itself. I'm using bridged network by lxc network. The setup looks like this</p>
<p>remote -> domain.com -> host -> container1 (nginx) -> container2 (app)</p>
<p>When I curl from a remote location this works quite fine:</p>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">
<p><span style="font-family: 'courier new', courier, monospace;">curl https://sub.domain.com</span><br /><span style="font-family: 'courier new', courier, monospace;"><html></html>%</span></p>
</blockquote>
<p>But when I'm doing the same from the host itself:</p>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">
<p><span style="font-family: 'courier new', courier, monospace;">curl https://<span>sub</span><span>.</span><span>domain</span><span>.</span><span>com</span></span><br /><span style="font-family: 'courier new', courier, monospace;">curl: (7) Failed to connect to <span>sub</span><span>.</span><span>domain</span><span>.</span><span>com</span> port 443: Connection refused</span></p>
</blockquote>
<p>I'm a little bit confused why this happens. I though it might be connected to iptables. But the rules look good for me:</p>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">
<p><span style="font-family: 'courier new', courier, monospace;">iptables-save </span><br /><span style="font-family: 'courier new', courier, monospace;"># Generated by iptables-save v1.6.1 on Sat Sep 2 02:24:33 2017</span><br /><span style="font-family: 'courier new', courier, monospace;">*nat</span><br /><span style="font-family: 'courier new', courier, monospace;">:PREROUTING ACCEPT [138088:14417714]</span><br /><span style="font-family: 'courier new', courier, monospace;">:INPUT ACCEPT [51357:4468554]</span><br /><span style="font-family: 'courier new', courier, monospace;">:OUTPUT ACCEPT [8593:788743]</span><br /><span style="font-family: 'courier new', courier, monospace;">:POSTROUTING ACCEPT [8445:711271]</span><br /><span style="font-family: 'courier new', courier, monospace;">-A PREROUTING -i ens18 -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.0.4.187:80</span><br /><span style="font-family: 'courier new', courier, monospace;">-A PREROUTING -i ens18 -p tcp -m tcp --dport 443 -j DNAT --to-destination 10.0.4.187:443</span><br /><span style="font-family: 'courier new', courier, monospace;">-A PREROUTING -i ens18 -p tcp -m tcp --dport 8022 -j DNAT --to-destination 10.0.4.116:8022</span><br /><span style="font-family: 'courier new', courier, monospace;">-A POSTROUTING -s 10.0.4.0/24 ! -d 10.0.4.0/24 -m comment --comment "generated for LXD network lxdbr0" -j MASQUERADE</span><br /><span style="font-family: 'courier new', courier, monospace;">COMMIT</span><br /><span style="font-family: 'courier new', courier, monospace;"># Completed on Sat Sep 2 02:24:33 2017</span><br /><span style="font-family: 'courier new', courier, monospace;"># Generated by iptables-save v1.6.1 on Sat Sep 2 02:24:33 2017</span><br /><span style="font-family: 'courier new', courier, monospace;">*mangle</span><br /><span style="font-family: 'courier new', courier, monospace;">:PREROUTING ACCEPT [293993:48599155]</span><br /><span style="font-family: 'courier new', courier, monospace;">:INPUT ACCEPT [188065:31562883]</span><br /><span style="font-family: 'courier new', courier, monospace;">:FORWARD ACCEPT [19475:7104838]</span><br /><span style="font-family: 'courier new', courier, monospace;">:OUTPUT ACCEPT [124159:16994042]</span><br /><span style="font-family: 'courier new', courier, monospace;">:POSTROUTING ACCEPT [147110:24355452]</span><br /><span style="font-family: 'courier new', courier, monospace;">-A POSTROUTING -o lxdbr0 -p udp -m udp --dport 68 -m comment --comment "generated for LXD network lxdbr0" -j CHECKSUM --checksum-fill</span><br /><span style="font-family: 'courier new', courier, monospace;">COMMIT</span><br /><span style="font-family: 'courier new', courier, monospace;"># Completed on Sat Sep 2 02:24:33 2017</span><br /><span style="font-family: 'courier new', courier, monospace;"># Generated by iptables-save v1.6.1 on Sat Sep 2 02:24:33 2017</span><br /><span style="font-family: 'courier new', courier, monospace;">*filter</span><br /><span style="font-family: 'courier new', courier, monospace;">:INPUT ACCEPT [449:65419]</span><br /><span style="font-family: 'courier new', courier, monospace;">:FORWARD ACCEPT [0:0]</span><br /><span style="font-family: 'courier new', courier, monospace;">:OUTPUT ACCEPT [274:37570]</span><br /><span style="font-family: 'courier new', courier, monospace;">-A INPUT -i lxdbr0 -p tcp -m tcp --dport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT</span><br /><span style="font-family: 'courier new', courier, monospace;">-A INPUT -i lxdbr0 -p udp -m udp --dport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT</span><br /><span style="font-family: 'courier new', courier, monospace;">-A INPUT -i lxdbr0 -p udp -m udp --dport 67 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT</span><br /><span style="font-family: 'courier new', courier, monospace;">-A FORWARD -o lxdbr0 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT</span><br /><span style="font-family: 'courier new', courier, monospace;">-A FORWARD -i lxdbr0 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT</span><br /><span style="font-family: 'courier new', courier, monospace;">-A OUTPUT -o lxdbr0 -p tcp -m tcp --sport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT</span><br /><span style="font-family: 'courier new', courier, monospace;">-A OUTPUT -o lxdbr0 -p udp -m udp --sport 53 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT</span><br /><span style="font-family: 'courier new', courier, monospace;">-A OUTPUT -o lxdbr0 -p udp -m udp --sport 67 -m comment --comment "generated for LXD network lxdbr0" -j ACCEPT</span><br /><span style="font-family: 'courier new', courier, monospace;">COMMIT</span><br /><span style="font-family: 'courier new', courier, monospace;"># Completed on Sat Sep 2 02:24:33 2017</span></p>
</blockquote>
<p><span>Might be the issue related to the bridged network or do you've any ideas what's causing the problem?!</span></p>
<p><br /></p>
<p><span>Thanks</span></p>
<p><span>Benjamin</span></p>
</body></html>