diff --git a/app/main.py b/app/main.py index a92bf37..2d4ad12 100644 --- a/app/main.py +++ b/app/main.py @@ -21,7 +21,8 @@ from flask import ( from . import engine, storage -app = Flask(__name__) +# Static unter /admin/static, damit Nginx nur eine /admin-Location braucht. +app = Flask(__name__, static_url_path="/admin/static") # Secret nur fuer Flash-Messages; bei Neustart verfallende Session ist ok. app.secret_key = os.environ.get("QT_SECRET_KEY") or os.urandom(16) diff --git a/deploy/nginx-table.lehrstun.de.conf b/deploy/nginx-table.lehrstun.de.conf new file mode 100644 index 0000000..ff26373 --- /dev/null +++ b/deploy/nginx-table.lehrstun.de.conf @@ -0,0 +1,22 @@ +# /etc/nginx/sites-available/table.lehrstun.de +# Oeffentliche Tabellen: statisch aus /var/www/table (App-Ausfall egal). +# Admin-Panel: Proxy auf gunicorn, hinter Basic Auth. +server { + listen 80; + server_name table.lehrstun.de; + + root /var/www/table; + index index.html; + + location = / { return 302 /admin/; } + location = /admin { return 302 /admin/; } + + location /admin/ { + auth_basic "QR-Tabellen Admin"; + auth_basic_user_file /etc/nginx/htpasswd-table; + proxy_pass http://127.0.0.1:8010; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-Proto $scheme; + client_max_body_size 10m; + } +} diff --git a/deploy/qr-tabellen.service b/deploy/qr-tabellen.service new file mode 100644 index 0000000..2ef53fa --- /dev/null +++ b/deploy/qr-tabellen.service @@ -0,0 +1,15 @@ +# /etc/systemd/system/qr-tabellen.service +[Unit] +Description=QR-Tabellen Admin-Panel (table.lehrstun.de) +After=network.target + +[Service] +User=herb +WorkingDirectory=/home/herb/qr-tabellen +Environment=QT_BASE_URL=https://table.lehrstun.de +Environment=QT_PUBLIC_DIR=/var/www/table +ExecStart=/home/herb/qr-tabellen/venv/bin/gunicorn -w 2 -b 127.0.0.1:8010 app.main:app +Restart=on-failure + +[Install] +WantedBy=multi-user.target