Fix port substitution and add support for static files

This commit is contained in:
Matthew Wild 2021-01-22 15:04:06 +00:00
parent ab87bc1144
commit 6293b45fbb
3 changed files with 24 additions and 9 deletions

View File

@ -5,11 +5,12 @@ CERT_PATH="/snikket/letsencrypt/live/$SNIKKET_DOMAIN/cert.pem"
export SNIKKET_TWEAK_HTTP_PORT=${SNIKKET_TWEAK_HTTP_PORT-80}
export SNIKKET_TWEAK_HTTPS_PORT=${SNIKKET_TWEAK_HTTPS_PORT-443}
export SNIKKET_TWEAK_INTERNAL_HTTP_PORT=${SNIKKET_TWEAK_INTERNAL_HTTP_PORT-5280}
export SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT=${SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT-8000}
while sleep 10; do
if test -f "$CERT_PATH"; then
for proto in http https; do
envsubst '$SNIKKET_DOMAIN $SNIKKET_TWEAK_HTTP_PORT $SNIKKET_TWEAK_HTTPS_PORT $SNIKKET_TWEAK_INTERNAL_HTTP_PORT' \
envsubst '$SNIKKET_DOMAIN $SNIKKET_TWEAK_HTTP_PORT $SNIKKET_TWEAK_HTTPS_PORT $SNIKKET_TWEAK_INTERNAL_HTTP_PORT $SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT' \
< /etc/nginx/templates/$proto \
> /etc/nginx/sites-enabled/$proto;
done

View File

@ -6,15 +6,23 @@ server {
server_name groups.${SNIKKET_DOMAIN};
server_name share.${SNIKKET_DOMAIN};
root /var/www/html;
location / {
try_files $uri @portal;
}
location @portal {
proxy_pass http://localhost:${SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT};
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
}
location /_/ {
proxy_pass http://localhost:${SNIKKET_TWEAK_INTERNAL_HTTP_PORT}/;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto http;
}
location ^~ /.well-known/acme-challenge {
allow all;
alias /var/www/html/.well-known/acme-challenge;
proxy_set_header X-Forwarded-Proto https;
}
}

View File

@ -15,15 +15,21 @@ server {
server_name groups.${SNIKKET_DOMAIN};
server_name share.${SNIKKET_DOMAIN};
root /var/www/html;
location / {
proxy_pass http://localhost:8000/;
try_files $uri @portal;
}
location @portal {
proxy_pass http://localhost:${SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT};
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
}
location /_/ {
proxy_pass http://localhost:5280/;
proxy_pass http://localhost:${SNIKKET_TWEAK_INTERNAL_HTTP_PORT}/;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;