2

How can we get the Apache instance in a private subnet to work?

Configuration
Public subnet with 1 NAT instance
Private subnet with 1 App instance

Details
1. Masquerading is turned on NAT on via

    iptables -t nat -A POSTROUTING -j MASQUERADE

2. PREROUTING is enabled via
iptables -t nat -A PREROUTING -p tcp --port 80 -j DNAT --to-destination 10.0.10.102:80
3. Port forwarding is enabled in /proc/sys/net/ipv4/ip_forward
4. Security group for both NAT & App (Would never keep these in production but purely to show all ports are open)

    Inbound All Traffic 0.0.0.0/0
    Outbound All Traffic 0.0.0.0/0

5. Network ACLs

    Inbound All Ports 0.0.0.0/0
    Outbound All Ports 0.0.0.0/0

6. Ping & wget work for external requests

    ping google.com
    wget google.com

7. Apache is listening on the App instance in the private subnet.

    netstat -tulpn
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
    tcp6       0      0 :::80                   :::*                    LISTEN      -

Apache Traffic
Public Requests to the Apache server on the private subnet does not work.

wget http://127.0.0.0.1/index.html   => success
# public IP requests
wget http://xxx.x.x.x/index.html   => failure
Connecting to xxx.x.x.x:80...      => hangs

From the NAT host terminal

sudo tcpdump -i any -n port 80
sudo: unable to resolve host ip-10-0-0-71
15:22:17.668089 IP 10.0.10.102.54033 > X.X.X.X.80: Flags [S], seq 848018267, win 26883, options [mss 8961,sackOK,TS val 19553465 ecr 0,nop,wscale 7], length 0
15:22:17.668111 IP 10.0.0.71.54033 > X.X.X.X.80: Flags [S], seq 848018267, win 26883, options [mss 8961,sackOK,TS val 19553465 ecr 0,nop,wscale 7], length 0

What do we need to do so Apache will work from the private subnet?

csi
  • 1,605
  • 7
  • 26
  • 43

0 Answers0