Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve ingress proxy configuration #18

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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