Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ docker-run:

docker-build-and-run: docker-build docker-run

docker-run-proxied: frontend-build docker-build
docker compose -f ./compose-behind-proxy.yml up

#############
# Front end #
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ If you want to test it locally, see [Docker](#docker).
| `ui.dashboard-subheading` | Dashboard description between header and endpoints | `Monitor the health of your endpoints in real-time` |
| `ui.header` | Header at the top of the dashboard. | `Gatus` |
| `ui.logo` | URL to the logo to display. | `""` |
| `ui.base` | `href` attribute of the HTML `<base>` tag. Use this if you want to host Gatus on a subpath (e.g. `/status/`). Has to end with '/'. | `/` |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this option might actually be better fit in the web config section and maybe also renaming it to make it easier to read without the actually reading the docs: web.base-path

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This time I'll ask before doing anything. The value of the 'base path' is needed by the 'UI config' (to render index.html) and by the 'security config' (for proper redirects and cookie paths). Currently, these parts are quite isolated, and I'm about to introduce a dependency from UI & security to web config. I can think of a plethora of ways of doing it, but I get a feeling there will be a few back-and-forth discussions over it 😉. What do you think about passing 'basePath' as an argument to 'ValidateAndSetDefaults' in these different configuration objects that need it? This way it won't introduce dependencies to 'web' config everywhere, will be easily mocked in tests, and this method is mutating everything anyway...or is somewhere else a pattern I can use?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently commited version does that. It is by no means final; still missing some validation and tests, but it works.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about passing 'basePath' as an argument to 'ValidateAndSetDefaults' in these different configuration objects that need it?

I think your suggested solution passing it as argument might not scale very well in case there are more options that have the same problem are added in the future.

I opened a PR on your fork with another solution that so far looks like it is consistent with the MaximumNumberOfResults storage option where we would not need to add any additional arguments or package dependencies.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this 'your' way has a drawback, that it makes it difficult to validate the RedirectURL in oidc configuration, as validation occurs before settings are distributed. But I'm not entirely sure there is a universe where not including a base-path in redirect url is a desired thing.

Anyway I think I've finished.

| `ui.link` | Link to open when the logo is clicked. | `""` |
| `ui.buttons` | List of buttons to display below the header. | `[]` |
| `ui.buttons[].name` | Text to display on the button. | Required `""` |
Expand Down
46 changes: 46 additions & 0 deletions compose-behind-proxy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
networks:
caddy_network:
name: gatus_proxy_network

services:
caddy:
networks:
- caddy_network
image: caddy:latest
container_name: gatus_proxy
ports:
- 8080:8080
configs:
- source: caddyfile
target: /etc/caddy/Caddyfile
gatus:
networks:
- caddy_network
image: twinproduction/gatus:latest
container_name: gatus_behind_proxy

volumes:
- ./config.yml:/config/02_config.yaml
environment:
- GATUS_CONFIG_PATH=/config
configs:
- source: gatus_config_ext
target: /config/01_config.yaml

configs:
gatus_config_ext:
content: |
ui:
base: /gatus/
caddyfile:
content: |
{
auto_https off
http_port 8080
}

http://localhost:8080 {
handle_path /gatus* {
reverse_proxy http://gatus_behind_proxy:8080
}
}
6 changes: 6 additions & 0 deletions config/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const (
defaultCustomCSS = ""
defaultSortBy = "name"
defaultFilterBy = "none"
defaultBase = "/"
)

var (
Expand All @@ -44,6 +45,7 @@ type Config struct {
DarkMode *bool `yaml:"dark-mode,omitempty"` // DarkMode is a flag to enable dark mode by default
DefaultSortBy string `yaml:"default-sort-by,omitempty"` // DefaultSortBy is the default sort option ('name', 'group', 'health')
DefaultFilterBy string `yaml:"default-filter-by,omitempty"` // DefaultFilterBy is the default filter option ('none', 'failing', 'unstable')
Base string `yaml:"base,omitempty"` // href attribute for HTML base tag
//////////////////////////////////////////////
// Non-configurable - used for UI rendering //
//////////////////////////////////////////////
Expand Down Expand Up @@ -86,6 +88,7 @@ func GetDefaultConfig() *Config {
DefaultSortBy: defaultSortBy,
DefaultFilterBy: defaultFilterBy,
MaximumNumberOfResults: storage.DefaultMaximumNumberOfResults,
Base: defaultBase,
}
}

Expand Down Expand Up @@ -115,6 +118,9 @@ func (cfg *Config) ValidateAndSetDefaults() error {
if len(cfg.CustomCSS) == 0 {
cfg.CustomCSS = defaultCustomCSS
}
if len(cfg.Base) == 0 {
cfg.Base = defaultBase
}
if cfg.DarkMode == nil {
cfg.DarkMode = &defaultDarkMode
}
Expand Down
38 changes: 36 additions & 2 deletions web/app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading