Access internal docker server from another computer.

hebrerillo

New Member
Joined
Mar 10, 2021
Messages
4
Reaction score
1
Credits
38
Hello everyone!

In a Linux computer, I have a docker that is running an HTTPS server on an internal IP: 192.168.1.164.

Let's suppose the Linux computer has a public IP of 14.14.14.14 (running on interface eno1).

I want to acceess the HTTPS server from another computer in the same network. To forward HTTPS port 443, I tried using 'iptables' like this:

iptables -t nat -A PREROUTING -i eno1 -p tcp --dport 443 -j DNAT --to-destination 192.168.1.164:443
iptables -t nat -A POSTROUTING -o eno1 -j MASQUERADE

With no success. Also tried other iptables commands with no success either.

How can I redirect HTTP requests to the internal docker server?

Here is the output of the command 'ip a' in my Linux computer:

Code:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 50:65:f3:4b:4f:de brd ff:ff:ff:ff:ff:ff
    inet 14.14.14.14/22 brd 14.14.14.255 scope global dynamic noprefixroute eno1
       valid_lft 78558sec preferred_lft 78558sec
    inet6 fe80::5265:f3ff:fe4b:4fde/64 scope link
       valid_lft forever preferred_lft forever
3: vmnet1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 1000
    link/ether 00:50:56:c0:00:01 brd ff:ff:ff:ff:ff:ff
    inet 172.16.209.1/24 brd 172.16.209.255 scope global vmnet1
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fec0:1/64 scope link
       valid_lft forever preferred_lft forever
4: vmnet8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 1000
    link/ether 00:50:56:c0:00:08 brd ff:ff:ff:ff:ff:ff
    inet 172.16.171.1/24 brd 172.16.171.255 scope global vmnet8
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fec0:8/64 scope link
       valid_lft forever preferred_lft forever
5: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    link/ether 02:42:18:4f:ea:9d brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
6: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether fe:c1:24:7b:93:71 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.1/24 scope global br0
       valid_lft forever preferred_lft forever
    inet6 fe80::148c:b6ff:fe0f:eb75/64 scope link
       valid_lft forever preferred_lft forever
7: tap0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UNKNOWN group default qlen 1000
    link/ether fe:c1:24:7b:93:71 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fcc1:24ff:fe7b:9371/64 scope link
       valid_lft forever preferred_lft forever

thank you!
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Linux.org Hosting Donations
Consider making a donation

Members online


Top