Skip to content

Commit 4f634ed

Browse files
feat(contrib/ec2): Setup proxy protocol by default
1 parent 5ece6fd commit 4f634ed

3 files changed

Lines changed: 39 additions & 5 deletions

File tree

contrib/ec2/deis.template.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,20 +287,29 @@
287287
"HealthCheck": {
288288
"HealthyThreshold": "4",
289289
"Interval": "15",
290-
"Target": "HTTP:80/health-check",
290+
"Target": "TCP:80",
291291
"Timeout": "5",
292292
"UnhealthyThreshold": "2"
293293
},
294294
"Subnets": [
295295
{ "Ref" : "Subnet1" },
296296
{ "Ref" : "Subnet2" }
297297
],
298+
"Policies" : [{
299+
"PolicyName" : "EnableProxyProtocol",
300+
"PolicyType" : "ProxyProtocolPolicyType",
301+
"Attributes" : [{
302+
"Name" : "ProxyProtocol",
303+
"Value" : "true"
304+
}],
305+
"InstancePorts" : ["80", "443"]
306+
}],
298307
"Listeners": [
299308
{
300309
"InstancePort": "80",
301-
"InstanceProtocol": "HTTP",
310+
"InstanceProtocol": "TCP",
302311
"LoadBalancerPort": "80",
303-
"Protocol": "HTTP"
312+
"Protocol": "TCP"
304313
},
305314
{
306315
"InstancePort": "443",

contrib/ec2/provision-ec2-cluster.sh

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ SLEEPTIME=10
5555
COUNTER=1
5656
INSTANCE_IDS=""
5757
until [ $(wc -w <<< $INSTANCE_IDS) -eq $DEIS_NUM_INSTANCES -a "$STACK_STATUS" = "CREATE_COMPLETE" ]; do
58-
if [ $COUNTER -gt $ATTEMPTS ]; then
58+
if [ $COUNTER -gt $ATTEMPTS ]; then
5959
echo "Provisioning instances failed (timeout, $(wc -w <<< $INSTANCE_IDS) of $DEIS_NUM_INSTANCES provisioned after 10m)"
6060
echo "Destroying stack $STACK_NAME"
6161
bailout
6262
exit 1
6363
fi
6464

6565
STACK_STATUS=$(aws --output text cloudformation describe-stacks --stack-name $STACK_NAME --query 'Stacks[].StackStatus')
66-
if [ $STACK_STATUS != "CREATE_IN_PROGRESS" -a $STACK_STATUS != "CREATE_COMPLETE" ] ; then
66+
if [ $STACK_STATUS != "CREATE_IN_PROGRESS" -a $STACK_STATUS != "CREATE_COMPLETE" ] ; then
6767
echo "error creating stack: "
6868
aws --output text cloudformation describe-stack-events \
6969
--stack-name $STACK_NAME \
@@ -127,3 +127,20 @@ echo "Using ELB $ELB_NAME at $ELB_DNS_NAME"
127127
128128
echo_green "Your Deis cluster has been successfully deployed to AWS CloudFormation and is started."
129129
echo_green "Please continue to follow the instructions in the documentation."
130+
131+
FIRST_INSTANCE=$(aws ec2 describe-instances \
132+
--filters Name=tag:aws:cloudformation:stack-name,Values=$STACK_NAME Name=instance-state-name,Values=running \
133+
--query 'Reservations[].Instances[].[PublicIpAddress]' \
134+
--output text | head -1)
135+
echo_green "Setting DEISCTL_TUNNEL=$FIRST_INSTANCE"
136+
export DEISCTL_TUNNEL=$FIRST_INSTANCE
137+
echo_green "Enabling proxy protocol"
138+
139+
if ! deisctl config router set proxyProtocol=1; then
140+
echo_red "#"
141+
echo_red "# Enabling proxy protocol failed, please enable proxy protocol "
142+
echo_red "# manually after finishing your deis cluster installation."
143+
echo_red "#"
144+
echo_red "# deisctl config router set proxyProtocol=1"
145+
echo_red "#"
146+
fi

docs/installing_deis/aws.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,13 @@ Run the cloudformation provision script to spawn a new CoreOS cluster:
189189
The default name of the CloudFormation stack will be ``deis``. You can specify a different name
190190
with ``./provision-ec2-cluster.sh <name>``.
191191

192+
Remote IPs behind your ELB
193+
--------------------------
194+
195+
The ELB you just created is load-balancing raw TCP connections, which is required for custom domain SSL
196+
and WebSockets. As remote IPs are by default not visible behind a TCP-Proxy, the ELB and your cluster routers
197+
were created with `Proxy Protocol`_ enabled.
198+
192199

193200
Configure DNS
194201
-------------
@@ -229,3 +236,4 @@ Please reference the AWS documentation for `more information about CloudFormatio
229236
.. _`PyYAML`: http://pyyaml.org/
230237
.. _`update_ec2_cluster.sh`: https://github.com/deis/deis/blob/master/contrib/ec2/update-ec2-cluster.sh
231238
.. _`More information about CloudFormation stack updates`: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks.html
239+
.. _`Proxy Protocol`: http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/enable-proxy-protocol.html

0 commit comments

Comments
 (0)