Skip to content
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
56 changes: 33 additions & 23 deletions .devcontainer/caddy/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand All @@ -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}"
}
Expand All @@ -55,30 +55,26 @@
route / {
# Inject link to manifest just after <head> tag
# https://developer.mozilla.org/docs/Web/Manifest
replace `<head>` `<head><link rel="manifest" href="manifest.json" />`
replace `<head>` `<head><link rel="manifest" href="manifest.json" crossorigin="use-credentials"/>`
}
# 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}
}
}

Expand All @@ -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/
Expand Down
40 changes: 40 additions & 0 deletions .devcontainer/caddy/srv/assets/foxglove/manifest.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
40 changes: 40 additions & 0 deletions .devcontainer/caddy/srv/assets/glances/manifest.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
23 changes: 23 additions & 0 deletions .devcontainer/caddy/srv/assets/gzweb/manifest.json
Original file line number Diff line number Diff line change
@@ -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"
}
23 changes: 23 additions & 0 deletions .devcontainer/caddy/srv/assets/nav2/manifest.json
Original file line number Diff line number Diff line change
@@ -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"
}
48 changes: 0 additions & 48 deletions .devcontainer/caddy/srv/index.md

This file was deleted.

32 changes: 0 additions & 32 deletions .devcontainer/caddy/srv/manifests/foxglove/manifest.json

This file was deleted.

15 changes: 0 additions & 15 deletions .devcontainer/caddy/srv/manifests/glances/manifest.json

This file was deleted.

15 changes: 0 additions & 15 deletions .devcontainer/caddy/srv/manifests/gzweb/manifest.json

This file was deleted.

8 changes: 0 additions & 8 deletions .devcontainer/caddy/srv/manifests/manifest.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<title>{{$title}}</title>
<meta name="color-scheme" content="light dark">
<link rel="stylesheet" href="github-markdown.css">
<link rel="icon" type="image/webp" href="/media/icons/nav2/any_icon_x512.webp">

<style>
body {
box-sizing: border-box;
Expand Down
Loading