Skip to content

Conversation

@pashagolub
Copy link
Collaborator

Users can now configure pgwatch to run under a custom path (e.g., http::/example.com/pgwatch) when behind a reverse proxy like Apache or Nginx.

  • add --web-base-path flag to specify custom path prefix
  • all API endpoints and static assets respect the configured base path
  • inject <base> tag and React Router basename dynamically at runtime
  • set homepage: "." in package.json for relative asset paths

Example usage:
pgwatch --web-base-path=pgwatch --web-addr=:8080

Then configure reverse proxy to forward /pgwatch/* to localhost:8080/pgwatch/*

Users can now configure pgwatch to run under a custom path
(e.g., http::/example.com/pgwatch) when behind a reverse proxy like
Apache or Nginx.

- add `--web-base-path` flag to specify custom path prefix
- all API endpoints and static assets respect the configured base path
- inject `<base>` tag and React Router `basename` dynamically at runtime
- set `homepage: "."` in `package.json` for relative asset paths

Example usage:
  pgwatch --web-base-path=pgwatch --web-addr=:8080

Then configure reverse proxy to forward `/pgwatch/*` to
`localhost:8080/pgwatch/*`
@pashagolub pashagolub self-assigned this Dec 2, 2025
@pashagolub pashagolub added enhancement New feature or request webui Admin UI related issues rest api REST API related issues labels Dec 2, 2025
@pashagolub
Copy link
Collaborator Author

@df7cb I'd really appreciate if you can test this one! Thanks in advance!

@coveralls
Copy link

coveralls commented Dec 2, 2025

Pull Request Test Coverage Report for Build 19886770242

Details

  • 119 of 130 (91.54%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.03%) to 73.615%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/webserver/source.go 20 21 95.24%
internal/webserver/metric.go 40 42 95.24%
internal/webserver/webserver.go 49 57 85.96%
Totals Coverage Status
Change from base Build 19859656383: -0.03%
Covered Lines: 3694
Relevant Lines: 5018

💛 - Coveralls

@df7cb
Copy link
Member

df7cb commented Dec 2, 2025

Thanks for the quick response. I tested the change and everything works like it should ✔️

The only thing I would change is to fold the Apache WS configuration into the "main" Apache config snippet. The ProxyPass /pgwatch/log lines need to go before the /pgwatch ones or else the log proxy doesn't work. Perhaps there could be a "this is optional, leave out if you don't need the Logs tab" comment.

@pashagolub
Copy link
Collaborator Author

@df7cb if you could show me how it should look like... Never worked with Apache

@pashagolub pashagolub merged commit 03d4c7d into master Dec 3, 2025
9 checks passed
@pashagolub pashagolub deleted the 1049-add-web-base-path branch December 3, 2025 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request rest api REST API related issues webui Admin UI related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants