Last active
April 16, 2019 07:55
-
-
Save coderbyheart/88e14753ccd7d0a8af9e6869829e7fcc to your computer and use it in GitHub Desktop.
Elastic Beanstalk Nginx Configuration File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
umask 077 | |
answers() { | |
echo -- | |
echo SomeState | |
echo SomeCity | |
echo SomeOrganization | |
echo SomeOrganizationalUnit | |
echo localhost.localdomain | |
echo root@localhost.localdomain | |
} | |
if [ $# -eq 0 ] ; then | |
echo $"Usage: `basename $0` filename [...]" | |
exit 0 | |
fi | |
for target in $@ ; do | |
PEM1=`/bin/mktemp /tmp/openssl.XXXXXX` | |
PEM2=`/bin/mktemp /tmp/openssl.XXXXXX` | |
trap "rm -f $PEM1 $PEM2" SIGINT | |
answers | /usr/bin/openssl req -newkey rsa:2048 -keyout $PEM1 -nodes -x509 -days 365 -out $PEM2 2> /dev/null | |
cat $PEM1 > ${target} | |
echo "" >> ${target} | |
cat $PEM2 >> ${target} | |
rm -f $PEM1 $PEM2 | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Elastic Beanstalk Nginx Configuration File | |
user nginx; | |
error_log /var/log/nginx/error.log warn; | |
pid /var/run/nginx.pid; | |
worker_processes auto; | |
worker_rlimit_nofile 15636; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | |
'$status $body_bytes_sent "$http_referer" ' | |
'"$http_user_agent" "$http_x_forwarded_for"'; | |
include conf.d/*.conf; | |
map $http_upgrade $connection_upgrade { | |
default "upgrade"; | |
} | |
server { | |
listen 80 default_server; | |
access_log /var/log/nginx/access.log main; | |
client_header_timeout 60; | |
client_body_timeout 60; | |
keepalive_timeout 60; | |
gzip off; | |
gzip_comp_level 4; | |
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript; | |
# Include the Elastic Beanstalk generated locations | |
include conf.d/elasticbeanstalk/*.conf; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -eq 0 ]; then | |
echo $"Usage: `basename $0` filename" 1>&2 | |
exit 1 | |
fi | |
PEM=$1 | |
REQ=`/bin/mktemp /tmp/openssl.XXXXXX` | |
KEY=`/bin/mktemp /tmp/openssl.XXXXXX` | |
CRT=`/bin/mktemp /tmp/openssl.XXXXXX` | |
NEW=${PEM}_ | |
trap "rm -f $REQ $KEY $CRT $NEW" SIGINT | |
if [ ! -f $PEM ]; then | |
echo "$PEM: file not found" 1>&2 | |
exit 1 | |
fi | |
let -a SERIAL=0x$(openssl x509 -in $PEM -noout -serial | cut -d= -f2) | |
let SERIAL++ | |
umask 077 | |
OWNER=`ls -l $PEM | awk '{ printf "%s.%s", $3, $4; }'` | |
openssl rsa -inform pem -in $PEM -out $KEY | |
openssl x509 -x509toreq -in $PEM -signkey $KEY -out $REQ | |
openssl x509 -req -in $REQ -signkey $KEY -set_serial $SERIAL -days 365 \ | |
-extfile /etc/pki/tls/openssl.cnf -extensions v3_ca -out $CRT | |
(cat $KEY ; echo "" ; cat $CRT) > $NEW | |
chown $OWNER $NEW | |
mv -f $NEW $PEM | |
rm -f $REQ $KEY $CRT | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment