diff --git a/.devcontainer/caddy/Caddyfile b/.devcontainer/caddy/Caddyfile index 74a9df93b28..1150579a47a 100644 --- a/.devcontainer/caddy/Caddyfile +++ b/.devcontainer/caddy/Caddyfile @@ -7,7 +7,7 @@ # Matcher for http request scheme. E.g. "http" or "https" @http_scheme { - expression {http.request.scheme}=="https" || {header.X-Forwarded-Scheme}=="https" + expression {http.request.scheme}=="https" || {header.X-Forwarded-Scheme}=="https" || {header.X-Forwarded-Proto}=="https" } # If any http scheme is "https", then use "wss" vars @http_scheme WsScheme "wss" @@ -19,9 +19,9 @@ header X-Forwarded-Host * } # If http headers exists, then use them - vars @host_forwarded WsHost {header.X-Forwarded-Host} + vars @host_forwarded ReqHost {header.X-Forwarded-Host} # Else default to host in request - vars WsHost {http.request.hostport} + vars ReqHost {http.request.hostport} # Matcher for websocket connection upgrade requests @websockets { @@ -37,8 +37,8 @@ # E.g auto redirect websocket URL to match request scheme (redirect) { # Configure redirect to match request scheme - vars LayoutUrl "/assets/nav2_foxglove_layout.json" - vars DataSourceUrl "{vars.WsScheme}://{vars.WsHost}{args.0}/" + vars LayoutUrl "/assets/foxglove/nav2_layout.json" + vars DataSourceUrl "{vars.WsScheme}://{vars.ReqHost}{args.0}/" redir /autoconnect "{args.0}/?ds=foxglove-websocket&ds.url={vars.DataSourceUrl}" redir /autolayout "{args.0}/?ds=foxglove-websocket&ds.url={vars.DataSourceUrl}&layoutUrl={vars.LayoutUrl}" } @@ -55,30 +55,26 @@ route / { # Inject link to manifest just after
tag # https://developer.mozilla.org/docs/Web/Manifest - replace `` `` + replace `` `` } # Redirect relative handle_path'ed manifest.json to /manifests directory - redir /manifest.json /manifests{http.request.orig_uri.path.dir}manifest.json + redir /manifest.json /assets{http.request.orig_uri.path.dir}manifest.json } # Snippet for hosted web app using websockets # to serve static files and reverse proxying connections # E.g. for serving GzWeb and Foxglove web apps (app) { - # Redirect implicit directory requests twards index.html - redir {args.0} {args.0}/ # handle and strip path prefix from redirect handle_path {args.0}/* { # Set root directory for static files - root * {args.1} - # Serve static files - file_server + root * {http.vars.root}{args.0} # Enable mobile web app features import mobile # Reverse proxy websockets to backend address - reverse_proxy @websockets {args.2} + reverse_proxy @websockets {args.1} # Import custom snippets - import {args.3} {args.0} + import {args.2} {args.0} } } @@ -88,24 +84,38 @@ :8080 { # Include global matchers and variables import globals + root * {$ROOT_SRV:/srv} + file_server browse - # Handle main landing page + # Handle root content + # I.e. assets internal to workspace handle /* { - # Use relative path for root directory - root * srv - file_server - import mobile - # Render markdown files as html - templates # Template manifest.json files templates */manifest.json { mime application/json } } + # Handle nav2 web app + # I.e. main landing page + handle_path /nav2/* { + root * {http.vars.root}/nav2 + import mobile + # Render markdown files as html + templates + } + + # Matcher for requests without browse query + @no_browse { + path / + not query browse=true + } + # Redirect to nav2 web app by default + redir @no_browse /nav2/ + # Import app snippets for web apps - import app "/gzweb" "{$GZWEB_WS}/http/client" "localhost:9090" "dummy" - import app "/foxglove" "{$FOXGLOVE_WS}" "localhost:8765" "redirect" + import app "/gzweb" "localhost:9090" "dummy" + import app "/foxglove" "localhost:8765" "redirect" # Handle glances web app redir /glances /glances/ diff --git a/.devcontainer/caddy/srv/assets/foxglove/manifest.json b/.devcontainer/caddy/srv/assets/foxglove/manifest.json new file mode 100644 index 00000000000..0b9b8b84d7e --- /dev/null +++ b/.devcontainer/caddy/srv/assets/foxglove/manifest.json @@ -0,0 +1,40 @@ +{ + "name": "Foxglove: {{placeholder "http.vars.ReqHost"}}", + "short_name": "Foxglove: {{placeholder "http.vars.ReqHost"}}", + "icons": [ + { + "src": "/media/icons/foxglove/any_icon_x512.webp", + "sizes": "512x512", + "type": "image/webp", + "purpose": "any" + }, + { + "src": "/media/icons/foxglove/maskable_icon_x512.webp", + "sizes": "512x512", + "type": "image/webp", + "purpose": "maskable" + } + ], + "id": "/foxglove/", + "start_url": "/foxglove/autoconnect", + "theme_color": "#6F3BE8", + "background_color": "#6F3BE8", + "display": "fullscreen", + "shortcuts" : [ + { + "name": "Auto Connect", + "url": "/foxglove/autoconnect", + "description": "Auto connect to default data source" + }, + { + "name": "Auto Layout", + "url": "/foxglove/autolayout", + "description": "Auto connect using default layout" + }, + { + "name": "Manual Connect", + "url": "/foxglove/", + "description": "Manually connect to data source" + } + ] +} diff --git a/.devcontainer/caddy/srv/assets/nav2_foxglove_layout.json b/.devcontainer/caddy/srv/assets/foxglove/nav2_layout.json similarity index 100% rename from .devcontainer/caddy/srv/assets/nav2_foxglove_layout.json rename to .devcontainer/caddy/srv/assets/foxglove/nav2_layout.json diff --git a/.devcontainer/caddy/srv/assets/glances/manifest.json b/.devcontainer/caddy/srv/assets/glances/manifest.json new file mode 100644 index 00000000000..78d27cb0bd6 --- /dev/null +++ b/.devcontainer/caddy/srv/assets/glances/manifest.json @@ -0,0 +1,40 @@ +{ + "name": "Glances: {{placeholder "http.vars.ReqHost"}}", + "short_name": "Glances: {{placeholder "http.vars.ReqHost"}}", + "icons": [ + { + "src": "/media/icons/glances/any_icon_x512.webp", + "sizes": "512x512", + "type": "image/webp", + "purpose": "any" + }, + { + "src": "/media/icons/glances/maskable_icon_x512.webp", + "sizes": "512x512", + "type": "image/webp", + "purpose": "maskable" + } + ], + "id": "/glances/", + "start_url": "/glances/", + "theme_color": "#2C363F", + "background_color": "#2C363F", + "display": "fullscreen", + "shortcuts" : [ + { + "name": "Refresh 1sec", + "url": "/glances/1", + "description": "Refresh page every 1 second" + }, + { + "name": "Refresh 5sec", + "url": "/glances/5", + "description": "Refresh page every 5 seconds" + }, + { + "name": "Refresh 10sec", + "url": "/glances/10", + "description": "Refresh page every 10 seconds" + } + ] +} diff --git a/.devcontainer/caddy/srv/assets/gzweb/manifest.json b/.devcontainer/caddy/srv/assets/gzweb/manifest.json new file mode 100644 index 00000000000..0596075f158 --- /dev/null +++ b/.devcontainer/caddy/srv/assets/gzweb/manifest.json @@ -0,0 +1,23 @@ +{ + "name": "Gzweb: {{placeholder "http.vars.ReqHost"}}", + "short_name": "Gzweb: {{placeholder "http.vars.ReqHost"}}", + "icons": [ + { + "src": "/media/icons/gzweb/any_icon_x512.webp", + "sizes": "512x512", + "type": "image/webp", + "purpose": "any" + }, + { + "src": "/media/icons/gzweb/maskable_icon_x512.webp", + "sizes": "512x512", + "type": "image/webp", + "purpose": "maskable" + } + ], + "id": "/gzweb/", + "start_url": "/gzweb/", + "theme_color": "#ffffff", + "background_color": "#ffffff", + "display": "fullscreen" +} diff --git a/.devcontainer/caddy/srv/assets/nav2/manifest.json b/.devcontainer/caddy/srv/assets/nav2/manifest.json new file mode 100644 index 00000000000..f482a47e803 --- /dev/null +++ b/.devcontainer/caddy/srv/assets/nav2/manifest.json @@ -0,0 +1,23 @@ +{ + "name": "Nav2: {{placeholder "http.vars.ReqHost"}}", + "short_name": "Nav2: {{placeholder "http.vars.ReqHost"}}", + "icons": [ + { + "src": "/media/icons/nav2/any_icon_x512.webp", + "sizes": "512x512", + "type": "image/webp", + "purpose": "any" + }, + { + "src": "/media/icons/nav2/maskable_icon_x512.webp", + "sizes": "512x512", + "type": "image/webp", + "purpose": "maskable" + } + ], + "id": "/nav2/", + "start_url": "/nav2/", + "theme_color": "#ffffff", + "background_color": "#ffffff", + "display": "standalone" +} diff --git a/.devcontainer/caddy/srv/index.md b/.devcontainer/caddy/srv/index.md deleted file mode 100644 index acaec1c52c4..00000000000 --- a/.devcontainer/caddy/srv/index.md +++ /dev/null @@ -1,48 +0,0 @@ -{ - "title": "Web Server" -} -## Hosted Apps - -Redirects for available web apps: - -| App | Links | -|-|-| -| [](foxglove/autolayout) | [**Foxglove Studio**](foxglove/autolayout) | -| [](gzweb) | [**Gzweb Client**](gzweb) | -| [](glances) | [**System Monitor**](glances) | - -## External Resources - -For more related documentation: - -- [Nav2 Documentation](https://navigation.ros.org) - - [Development Guides](https://navigation.ros.org/development_guides) - - [Dev Containers](https://navigation.ros.org/development_guides/devcontainer_docs) - -## Session Info - -Useful information about host server and remote client: - -|Key | Value | -|-|-| -| Host | `{{.Host}}` | -| Remote IP | `{{placeholder "http.request.remote.host"}}` | -| Date | `{{now}}` | - -### Server Diagnostics - -