Configure nginx to show update page when stopping box

This code was moved from the installer code
This commit is contained in:
Girish Ramakrishnan
2015-01-22 00:16:29 -08:00
parent 117f4580ab
commit 357617997e
5 changed files with 209 additions and 0 deletions
+80
View File
@@ -0,0 +1,80 @@
types {
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
application/x-javascript js;
application/atom+xml atom;
application/rss+xml rss;
text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;
image/png png;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;
image/svg+xml svg svgz;
image/webp webp;
application/java-archive jar war ear;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.ms-excel xls;
application/vnd.ms-powerpoint ppt;
application/vnd.wap.wmlc wmlc;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/x-7z-compressed 7z;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/xhtml+xml xhtml;
application/zip zip;
application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream eot;
application/octet-stream iso img;
application/octet-stream msi msp msm;
audio/midi mid midi kar;
audio/mpeg mp3;
audio/ogg ogg;
audio/x-m4a m4a;
audio/x-realaudio ra;
video/3gpp 3gpp 3gp;
video/mp4 mp4;
video/mpeg mpeg mpg;
video/quicktime mov;
video/webm webm;
video/x-flv flv;
video/x-m4v m4v;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
}
+58
View File
@@ -0,0 +1,58 @@
user www-data;
worker_processes 1;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
root /home/yellowtent/box/setup/website;
index index.html;
server {
listen 80;
location / {
# redirect everything to HTTPS
return 301 https://$host$request_uri;
}
}
# HTTPS server
server {
listen 443;
error_page 503 /index.html;
location /index.html {
# allow access to this page
add_header Cache-Control no-cache;
}
location /3rdparty/bootstrap.min.css {
# allow access to this page
add_header Cache-Control no-cache;
}
location / {
return 503;
}
ssl on;
ssl_certificate cert/host.cert;
ssl_certificate_key cert/host.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # don't use SSLv3 ref: POODLE
ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
ssl_prefer_server_ciphers on;
}
}
+30
View File
@@ -2,6 +2,36 @@
set -e
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly NGINX_CONFIG_DIR=/home/yellowtent/setup_configs/nginx # do not reuse configs since it will be removed by installer
readonly CERT_DIR="/home/yellowtent/configs/nginx/cert"
setup_nginx() {
if [[ ! -f "${CERT_DIR}/host.key" || ! -f "${CERT_DIR}/host.key" ]]; then
echo "Skipping settings up nginx since no certs found"
return
fi
echo "Setting up nginx update page"
# show updating page in nginx
local provision_tls_cert=$(cat "${CERT_DIR}/host.cert")
local provision_tls_key=$(cat "${CERT_DIR}/host.key")
unlink /etc/nginx 2>/dev/null || rm -rf /etc/nginx
rm -rf "${NGINX_CONFIG_DIR}" && mkdir -p "${NGINX_CONFIG_DIR}"
ln -s "${NGINX_CONFIG_DIR}" /etc/nginx
cp "${SCRIPT_DIR}/nginx/nginx.conf" "${NGINX_CONFIG_DIR}/nginx.conf"
cp "${SCRIPT_DIR}/nginx/mime.types" "${NGINX_CONFIG_DIR}/mime.types"
mkdir -p "${NGINX_CONFIG_DIR}/cert"
echo "${provision_tls_cert}" > "${NGINX_CONFIG_DIR}/cert/host.cert"
echo "${provision_tls_key}" > "${NGINX_CONFIG_DIR}/cert/host.key"
nginx -s reload
}
setup_nginx
echo "Stopping box code"
service supervisor stop || true
File diff suppressed because one or more lines are too long
+36
View File
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" />
<title> Cloudron Webadmin </title>
<link href="3rdparty/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<!-- Modal update progress -->
<div class="modal show" id="updateProgressModal" tabindex="-1" role="dialog" aria-labelledby="updateProgressModalLabel" aria-hidden="true" data-keyboard ="false" data-backdrop="static">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="updateProgressModalLabel">Update in progress...</h4>
</div>
<div class="modal-body">
<div class="progress progress-striped active">
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%"></div>
</div>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<script>
setTimeout(location.reload.bind(location, true /* forceGet from server */), 10000);
</script>
</body>
</html>