Skip to content

Commit

Permalink
Do all rewriting in rev-propxy
Browse files Browse the repository at this point in the history
  • Loading branch information
lildude committed Apr 28, 2024
1 parent f5f8a39 commit 8aea43b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
7 changes: 5 additions & 2 deletions rootfs/etc/nginx/conf.d/ghostfolio.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@ server {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Referer $http_referer;
proxy_set_header Origin "";
proxy_set_header X-Real-IP $remote_addr;

proxy_pass http://127.0.0.1:3333;
proxy_redirect '/' $http_x_ingress_path/;
proxy_set_header Accept-Encoding "";
proxy_set_header X-Ingress-Path $http_x_ingress_path;

sub_filter_types *;
sub_filter_once off;
sub_filter 'href="/' 'href="$http_x_ingress_path/';
sub_filter '<script src="/' '<script src="$http_x_ingress_path/';
sub_filter "top.location.href='" "top.location.href='$http_x_ingress_path";
sub_filter "`/api" "`$http_x_ingress_path/api";
sub_filter '"/api' "\"$http_x_ingress_path/api";
sub_filter '/assets' "$http_x_ingress_path/assets";
}
}
17 changes: 0 additions & 17 deletions rootfs/etc/services.d/ghostfolio/run
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,6 @@ DATABASE_URL="postgresql://$POSTGRES_USER:$POSTGRES_PASS@$POSTGRES_HOST:$POSTGRE
export ACCESS_TOKEN_SALT JWT_SECRET_KEY POSTGRES_HOST POSTGRES_DB POSTGRES_PASS POSTGRES_PORT POSTGRES_USER \
API_KEY_COINGECKO_DEMO API_KEY_COINGECKO_PRO REDIS_HOST REDIS_PORT NODE_ENV DATABASE_URL

ingress_entry=$(curl -X GET \
-H "Authorization: Bearer ${SUPERVISOR_TOKEN}" \
-H "Content-Type: application/json" \
-s http://supervisor/addons/self/info | \
jq -r '.data.ingress_entry')

if bashio::var.is_empty "$(bashio::addon.port 3333)"; then
if [[ $(grep hassio_ingress /ghostfolio/apps/client/en/main.*.js) -eq 0 ]]; then
sed -Ei.direct "s^(\`|\")/api^\1${ingress_entry}/api^g" /ghostfolio/apps/client/*/*.js
sed -Ei.direct "s^\(/assets^\(${ingress_entry}/assets^g" /ghostfolio/apps/client/*/*.js
fi
else
if [[ $(find "/ghostfolio/apps/client/en/*.js.direct" 2> /dev/null | wc -l) -gt 0 ]]; then
find /ghostfolio/apps/ -name '*.direct' -exec sh -c 'echo "$0" "${0%.direct}"' {} \;
fi
fi

bashio::log.info "Starting Ghostfolio"
cd /ghostfolio/apps/api
if bashio::config.true 'silent'; then
Expand Down

0 comments on commit 8aea43b

Please sign in to comment.