From 5b82bbb5b340eb39412c540e33091ac8e596b562 Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Sun, 1 Sep 2013 14:24:49 +0000 Subject: [PATCH] preliminary script for nginx --- conf/nginx.conf | 30 ++++++++++++++++++++++++++++++ scripts/web.sh | 17 +++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 conf/nginx.conf create mode 100755 scripts/web.sh diff --git a/conf/nginx.conf b/conf/nginx.conf new file mode 100644 index 0000000..b27ec8e --- /dev/null +++ b/conf/nginx.conf @@ -0,0 +1,30 @@ +server { + listen 80; + listen [::]:80 default_server ipv6only=on; + listen 443 ssl; + + server_name $PUBLIC_HOSTNAME; + + ssl_certificate $STORAGE_ROOT/ssl/ssl_certificate.pem; + ssl_certificate_key $STORAGE_ROOT/ssl/ssl_private_key.pem; + + root $STORAGE_ROOT/www/static; + + index index.html index.htm; + + location / { + # First attempt to serve request as file, then + # as directory, then fall back to displaying a 404. + try_files $uri $uri/ /index.html; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + #error_page 500 502 503 504 /50x.html; + #location = /50x.html { + # root /usr/share/nginx/html; + #} +} + diff --git a/scripts/web.sh b/scripts/web.sh new file mode 100755 index 0000000..34c5e2d --- /dev/null +++ b/scripts/web.sh @@ -0,0 +1,17 @@ +# HTTP: Turn on a web server serving static files +################################################# + +apt-get install -q -y nginx + +rm -f /etc/nginx/sites-enabled/default.conf + +cat conf/nginx.conf \ + | sed "s/\$STORAGE_ROOT/$STORAGE_ROOT/g" \ + | sed "s/\$PUBLIC_HOSTNAME/$PUBLIC_HOSTNAME/g" \ + > /etc/nginx/sites-enabled/local.conf + +service nginx reload + +ufw allow http +ufw allow https +