Skip to content

Commit 961fff6

Browse files
committed
Add ec2 private ip to server name for LBs
Allow LBs to talk to application by adding the EC2 ipv4 address to server_name.
1 parent 051fae7 commit 961fff6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/docker-entrypoint.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ if [[ -n $PROXY_REVERSE_URL ]]; then
77
export UPSTREAM_SERVER=${PROXY_REVERSE_URL#http://}
88
fi
99

10+
# Add EC2 IPv4 address to allowed hosts so that load balancers can talk to us
11+
if [[ "$SERVER_NAME" != "_" ]]; then
12+
local_ipv4=$(curl --connect-timeout 2 -s http://169.254.169.254/2009-04-04/meta-data/local-ipv4 || true 2>/dev/null)
13+
if [[ -n "$local_ipv4" ]]
14+
then
15+
export SERVER_NAME="$SERVER_NAME $local_ipv4"
16+
fi
17+
fi
18+
1019
run-parts --exit-on-error /docker-entrypoint.d
1120

1221
exec "$@"

0 commit comments

Comments
 (0)