This commit is contained in:
Alexandre
2022-12-20 13:45:19 +01:00
parent 521863bb33
commit 7d5a54f577
7 changed files with 57 additions and 33 deletions

View File

@@ -1,18 +1,6 @@
#!/usr/bin/bashio
# shellcheck shell=bash
rm /etc/nginx/servers/ingress.conf
exit 0
########
# TEST #
########
if [ -f /config/tandoortest.sh ]; then
echo "running test file"
chmod +x /config/tandoortest.sh
/./config/tandoortest.sh
fi
#################
# NGINX SETTING #
#################

View File

@@ -16,12 +16,13 @@ for element in ${ALLOWED_HOSTS//,/ }; do # Separate comma separated values
CSRF_TRUSTED_ORIGINS="http://$element,https://$element,$CSRF_TRUSTED_ORIGINS"
done
export CSRF_TRUSTED_ORIGINS
export ALLOWED_HOSTS="*"
#################
# Allow ingress #
#################
sed -i "s|href=\"{% base_path request \'base\' %}\"|href=\"{% base_path request \'base\' %}/\"|g" /opt/recipes/cookbook/templates/base.html
#sed -i "s|href=\"{% base_path request \'base\' %}\"|href=\"{% base_path request \'base\' %}/\"|g" /opt/recipes/cookbook/templates/base.html
###################
# Define database #
@@ -71,6 +72,13 @@ case $(bashio::config 'DB_TYPE') in
bashio::log.warning "This addon is using the Maria DB addon"
bashio::log.warning "Please ensure this is included in your backups"
bashio::log.warning "Uninstalling the MariaDB addon will remove any data"
bashio::log.info "Creating database if required"
mysql \
-u "${POSTGRES_USER}" -p"${POSTGRES_PASSWORD}" \
-h "${POSTGRES_HOST}" -P "${POSTGRES_PORT}" \
-e "CREATE DATABASE IF NOT EXISTS \`${POSTGRES_DB}\` ;"
;;
postgresql_external)

View File

@@ -5,6 +5,7 @@ proxy_redirect off;
proxy_send_timeout 86400s;
proxy_max_temp_file_size 0;
proxy_set_header Host $http_host;
proxy_set_header Accept-Encoding "";
proxy_set_header Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;

View File

@@ -6,15 +6,28 @@ server {
root /opt/recipes/cookbook;
location /switch-space {
proxy_pass http://127.0.0.1:8080/switch-space;
proxy_set_header Host $http_host;
proxy_buffering off;
proxy_read_timeout 30;
proxy_set_header Connection "Upgrade";
proxy_set_header Upgrade $http_upgrade;
}
location /switch-space/ {
proxy_pass http://127.0.0.1:8080/switch-space/;
proxy_redirect "/" "%%ingress_entry%%/";
# Allow ingress subpath
#proxy_set_header X-Script-Name %%ingress_entry%%;
proxy_cookie_path / %%ingress_entry%%/;
# Allow frames
add_header X-Frame-Options SAMEORIGIN;
add_header Access-Control-Allow-Origin *;
proxy_set_header Accept-Encoding "";
absolute_redirect off;
sub_filter_once off;
sub_filter_types *;
sub_filter "/static" "%%ingress_entry%%/static";
sub_filter "/media" "%%ingress_entry%%/media";
sub_filter "http://127.0.0.1:8080/" "/";
}
location / {
proxy_pass http://127.0.0.1:8080;
@@ -22,7 +35,7 @@ server {
proxy_read_timeout 30;
proxy_set_header Connection "Upgrade";
proxy_set_header Upgrade $http_upgrade;
# Allow ingress subpath
proxy_set_header X-Script-Name %%ingress_entry%%;
proxy_cookie_path / %%ingress_entry%%/;
@@ -32,7 +45,7 @@ server {
add_header X-Frame-Options SAMEORIGIN; # Required for ingress frame
add_header Access-Control-Allow-Origin *;
proxy_set_header Accept-Encoding "";
# avoid mixed content
# Ensure work with both http and https (code by @met67)
if ($http_referer ~* "^(http[s]?)://([^:]+):(\d*)(/.*)$") {
@@ -51,7 +64,7 @@ server {
proxy_set_header X-Port $x_port;
proxy_set_header X-Forwarded-Proto $x_scheme;
proxy_set_header Host $host$x_port; # Required for addresses without ports
proxy_set_header Host $x_host$x_port; # Required for addresses without ports
# Correct url without port when using https
sub_filter_once off;
@@ -60,7 +73,16 @@ server {
sub_filter http://$x_host/ http://$x_host$x_port/;
# Rewrite url
sub_filter "/static/" "%%ingress_entry%%/static/";
sub_filter "/media/" "%%ingress_entry%%/media/";
sub_filter "/static" "%%ingress_entry%%/static";
sub_filter "/media" "%%ingress_entry%%/media";
}
location /media/ {
alias /config/addons_config/tandoor_recipes/mediafiles/;
}
location /static/ {
alias /data/recipes/staticfiles/;
}
}