~nchohan/appscale/GAE1.4.0-namespaces

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#! /bin/bash
. /etc/profile.d/appscale.sh

# flush the current setting
iptables -F

# allow all established connections 
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# Allow all loopback traffic
iptables -I INPUT 1 -i lo -j ACCEPT

# allow all ssh traffic 
iptables -A INPUT -p tcp --dport ssh -j ACCEPT

# allow for all traffic from anywhere for the following
iptables -A INPUT -p tcp --dport 80 -j ACCEPT          # nginx -> loadbalancer
iptables -A INPUT -p tcp --dport 443 -j ACCEPT         # nginx for ssl
iptables -A INPUT -p tcp --dport 8050 -j ACCEPT        # appmonitoring
iptables -A INPUT -p tcp --dport 8080:8090 -j ACCEPT   # nginx -> gae
iptables -A INPUT -p tcp --dport 17443 -j ACCEPT       # appcontroller
iptables -A INPUT -p tcp --dport 4343 -j ACCEPT        # user app server

ALL_IPS_FILE=${APPSCALE_HOME}/.appscale/all_ips
MASTER_FILE=${APPSCALE_HOME}/.appscale/masters
SLAVES_FILE=${APPSCALE_HOME}/.appscale/slaves

# allow any connections coming from within the cluster
cat $ALL_IPS_FILE $MASTER_FILE $SLAVES_FILE | sort -u | while read line; do
  test -n "$line" && iptables -A INPUT -s ${line} -j ACCEPT
done

# drop all else
iptables -A INPUT -j DROP