generated from coop-cloud/example
add FALLBACK_REDIRECT_URL to be able to redirect any unknown paths to a different domain
Some checks failed
continuous-integration/drone/pr Build is failing
Some checks failed
continuous-integration/drone/pr Build is failing
This commit is contained in:
@ -6,6 +6,7 @@ DOMAIN=custom-html.example.com
|
|||||||
LETS_ENCRYPT_ENV=production
|
LETS_ENCRYPT_ENV=production
|
||||||
|
|
||||||
COMPOSE_FILE="compose.yml"
|
COMPOSE_FILE="compose.yml"
|
||||||
|
HTML_ROOT=/usr/share/nginx/html
|
||||||
|
|
||||||
# Single Sign On via Traefik "file provider"
|
# Single Sign On via Traefik "file provider"
|
||||||
#COMPOSE_FILE="$COMPOSE_FILE:compose.sso.yml"
|
#COMPOSE_FILE="$COMPOSE_FILE:compose.sso.yml"
|
||||||
@ -13,7 +14,9 @@ COMPOSE_FILE="compose.yml"
|
|||||||
# Git-pull regularly
|
# Git-pull regularly
|
||||||
#COMPOSE_FILE="$COMPOSE_FILE:compose.git-pull.yml"
|
#COMPOSE_FILE="$COMPOSE_FILE:compose.git-pull.yml"
|
||||||
#GIT_REPO_URL="https://git.coopcloud.tech/dalmationer/hexbomb.gay"
|
#GIT_REPO_URL="https://git.coopcloud.tech/dalmationer/hexbomb.gay"
|
||||||
#CRON_SCHEDULE="*/1 * * * *"
|
#GIT_BRANCH=main
|
||||||
|
#CRON_SCHEDULE="*/10 * * * *" # Default: every 10 minutes
|
||||||
|
# HTML_ROOT=/git
|
||||||
|
|
||||||
# Optionally redirect the entire domain or a sub-path:
|
# Optionally redirect the entire domain or a sub-path:
|
||||||
# path under which you want to redirect all URLs (with trailing slash):
|
# path under which you want to redirect all URLs (with trailing slash):
|
||||||
@ -27,6 +30,10 @@ COMPOSE_FILE="compose.yml"
|
|||||||
# Optionally handle all URL requests using a single file (commonly index.html)
|
# Optionally handle all URL requests using a single file (commonly index.html)
|
||||||
#SINGLE_PAGE_SITE_HANDLER=/index.html
|
#SINGLE_PAGE_SITE_HANDLER=/index.html
|
||||||
|
|
||||||
|
# Optionally redirect URL requests if not file is found for the requested path
|
||||||
|
# FALLBACK_REDIRECT_URL=https://coopcloud.tech/
|
||||||
|
# FALLBACK_REDIRECT_TYPE=302
|
||||||
|
|
||||||
# Enable an SSH server to allow SFTP uploads to the web root
|
# Enable an SSH server to allow SFTP uploads to the web root
|
||||||
#COMPOSE_FILE="$COMPOSE_FILE:compose.sftp.yml"
|
#COMPOSE_FILE="$COMPOSE_FILE:compose.sftp.yml"
|
||||||
#PUBLIC_KEY="ssh-ed25519 AAAAC3NzaJ1lZDI1NTE5AAAAIXqf4nxUxuGmLOaxXXXXXXXXoM/GwhcrAgmtbgXToaYmCJ user@host" # Replace with a public key you generate
|
#PUBLIC_KEY="ssh-ed25519 AAAAC3NzaJ1lZDI1NTE5AAAAIXqf4nxUxuGmLOaxXXXXXXXXoM/GwhcrAgmtbgXToaYmCJ user@host" # Replace with a public key you generate
|
||||||
4
abra.sh
4
abra.sh
@ -1,2 +1,2 @@
|
|||||||
export NGINX_DEFAULT_CONF_VERSION=v6
|
export NGINX_DEFAULT_CONF_VERSION=v10
|
||||||
export ENTRYPOINT_CONF_VERSION=v3
|
export ENTRYPOINT_CONF_VERSION=v4
|
||||||
|
|||||||
@ -24,9 +24,12 @@ services:
|
|||||||
- "backupbot.backup.path=/usr/share/nginx/html"
|
- "backupbot.backup.path=/usr/share/nginx/html"
|
||||||
environment:
|
environment:
|
||||||
- DEFAULT_CONF_FILE=/etc/nginx/conf.d/default.conf
|
- DEFAULT_CONF_FILE=/etc/nginx/conf.d/default.conf
|
||||||
|
- HTML_ROOT
|
||||||
- REDIRECT_FROM_PATH
|
- REDIRECT_FROM_PATH
|
||||||
- REDIRECT_TO_URL
|
- REDIRECT_TO_URL
|
||||||
- REDIRECT_TYPE
|
- REDIRECT_TYPE
|
||||||
|
- FALLBACK_REDIRECT_URL
|
||||||
|
- FALLBACK_REDIRECT_TYPE
|
||||||
volumes:
|
volumes:
|
||||||
- content:/usr/share/nginx/html
|
- content:/usr/share/nginx/html
|
||||||
configs:
|
configs:
|
||||||
|
|||||||
@ -8,20 +8,34 @@ server {
|
|||||||
#access_log /var/log/nginx/host.access.log main;
|
#access_log /var/log/nginx/host.access.log main;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
root /usr/share/nginx/html;
|
root {{ env "HTML_ROOT" }};
|
||||||
index index.html index.htm;
|
index index.html index.htm;
|
||||||
|
|
||||||
{{ if env "REDIRECT_TO_URL" }}
|
{{ if env "REDIRECT_TO_URL" }}
|
||||||
rewrite ^{{ env "REDIRECT_FROM_PATH" }}(.*)$ {{ env "REDIRECT_TO_URL" }}$1 {{ env "REDIRECT_TYPE" }};
|
rewrite ^{{ env "REDIRECT_FROM_PATH" }}(.*)$ {{ env "REDIRECT_TO_URL" }}$1 {{ env "REDIRECT_TYPE" }};
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ if env "SINGLE_PAGE_SITE_HANDLER" }}
|
{{ if env "FALLBACK_REDIRECT_URL" }}
|
||||||
try_files $uri $uri/ {{ env "SINGLE_PAGE_SITE_HANDLER" }} =404;
|
# redirect unknown URLs (no matching files) to other address
|
||||||
|
try_files $uri $uri/ @fallback_redirect;
|
||||||
{{ else }}
|
{{ else }}
|
||||||
try_files $uri $uri/ $uri.html =404;
|
{{ if env "SINGLE_PAGE_SITE_HANDLER" }}
|
||||||
|
# serve SPA handler
|
||||||
|
try_files $uri $uri/ {{ env "SINGLE_PAGE_SITE_HANDLER" }} =404;
|
||||||
|
{{ else }}
|
||||||
|
# serve static files or regular 404 as usual
|
||||||
|
try_files $uri $uri/ $uri.html =404;
|
||||||
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{{ if env "FALLBACK_REDIRECT_URL" }}
|
||||||
|
location @fallback_redirect {
|
||||||
|
return {{ env "FALLBACK_REDIRECT_TYPE" }} {{ env "FALLBACK_REDIRECT_URL" }}$request_uri;
|
||||||
|
}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
# Standard static 404 error page
|
||||||
error_page 404 /404.html;
|
error_page 404 /404.html;
|
||||||
location = /404.html {
|
location = /404.html {
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
|
|||||||
@ -4,7 +4,7 @@ if [ ! -d /git/.git ]; then
|
|||||||
echo "No repo found, emptying /git/ directory"
|
echo "No repo found, emptying /git/ directory"
|
||||||
rm -r /git/*
|
rm -r /git/*
|
||||||
echo "Cloning $GIT_REPO_URL into /git"
|
echo "Cloning $GIT_REPO_URL into /git"
|
||||||
git clone "$GIT_REPO_URL" /git
|
git clone -b "$GIT_BRANCH" --single-branch "$GIT_REPO_URL" /git
|
||||||
else
|
else
|
||||||
echo "Updating /git"
|
echo "Updating /git"
|
||||||
git pull
|
git pull
|
||||||
|
|||||||
Reference in New Issue
Block a user