[GH-ISSUE #120] Set base url to serve behind a reverse proxy #102

Open
opened 2026-02-26 21:34:26 +03:00 by kerem · 1 comment
Owner

Originally created by @metinsenturk on GitHub (May 24, 2025).
Original GitHub issue: https://github.com/eduardolat/pgbackweb/issues/120

Using pgbackweb with a reverse proxy like nginx need BASE_URL so that application is aware that it is running under a web proxy and respects redirects like http://localhost/pgbackweb.

My current setup in nginx.conf file redirects http://localhost/pgbackweb to http://localhost/auth/create-first-user.

location /pgbackweb/ {
    proxy_pass http://pgbackweb_app/;
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Prefix /pgbackweb;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_redirect ^/ /pgbackweb/; 
    gzip off;
    sub_filter_once off;
    sub_filter 'href="/' 'href="/pgbackweb/';
    sub_filter 'src="/' 'src="/pgbackweb/';
}

However, I can see that app works if I manually go to http://localhost/pgbackweb/auth/create-first-user.

Can we add BASE_URL as an environment variable?

Thanks!

Originally created by @metinsenturk on GitHub (May 24, 2025). Original GitHub issue: https://github.com/eduardolat/pgbackweb/issues/120 Using pgbackweb with a reverse proxy like nginx need `BASE_URL` so that _application is aware_ that it is running under a web proxy and respects redirects like `http://localhost/pgbackweb`. My current setup in `nginx.conf` file redirects http://localhost/pgbackweb to http://localhost/auth/create-first-user. ```Nginx location /pgbackweb/ { proxy_pass http://pgbackweb_app/; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Prefix /pgbackweb; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_redirect ^/ /pgbackweb/; gzip off; sub_filter_once off; sub_filter 'href="/' 'href="/pgbackweb/'; sub_filter 'src="/' 'src="/pgbackweb/'; } ``` However, I can see that app works if I manually go to http://localhost/pgbackweb/auth/create-first-user. Can we add `BASE_URL` as an environment variable? Thanks!
Author
Owner

@eduardolat commented on GitHub (May 25, 2025):

I think all urls are expected to be relative to the root (/), not under a directory (/pgbackweb), i'll add the BASE_URL environment variable that you suggested in a future release

I'm out of time right now, but as soon as i can i'll continue adding this kind of features to the project

<!-- gh-comment-id:2908006784 --> @eduardolat commented on GitHub (May 25, 2025): I think all urls are expected to be relative to the root (/), not under a directory (/pgbackweb), i'll add the `BASE_URL` environment variable that you suggested in a future release I'm out of time right now, but as soon as i can i'll continue adding this kind of features to the project
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/pgbackweb#102
No description provided.