Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
5aeaefc
Add Caddyfile to reverse proxy websockets
ruffsl Apr 29, 2023
623a79c
Update caddy related tasks
ruffsl Apr 29, 2023
d067d57
Rename Gzweb task to Gzweb Bridge
ruffsl Apr 29, 2023
8d8ded7
Add Gzweb Client Task
ruffsl Apr 29, 2023
e4edafb
Add Caddyfile to reverse proxy websockets
ruffsl Apr 29, 2023
8123104
Specify config file to avoid crosstalk
ruffsl Apr 29, 2023
d6d9b95
Fix reverse proxy for websockets
ruffsl Apr 29, 2023
703d39f
Comment out log output files for debugging
ruffsl Apr 29, 2023
bb2ed73
Simplify tasks by removing client tasks
ruffsl May 1, 2023
c3193c1
Stop tasks by using terminate
ruffsl May 1, 2023
a48b0a9
Move Caddyfile
ruffsl May 1, 2023
23a973a
Add Web Server tasks
ruffsl May 1, 2023
f711837
Move Caddyfile
ruffsl May 1, 2023
d645646
Update log output file path
ruffsl May 1, 2023
f016345
Update root path
ruffsl May 1, 2023
8f364a5
Update reverse_proxy for both gzweb and foxglove
ruffsl May 1, 2023
bdbb951
Use snippets
ruffsl May 1, 2023
553a3c1
Use rewrite to catch trailing slash
ruffsl May 1, 2023
abd94c4
Improve websocket snippet
ruffsl May 1, 2023
2543d8e
Use header_regexp for case-insensitive matching
ruffsl May 1, 2023
447f655
Add helper index page to web server
ruffsl May 1, 2023
99bd63f
Limit templates to fix gzweb
ruffsl May 1, 2023
9a12a6f
Add comments to Cadyfile
ruffsl May 1, 2023
50b1fa2
Stage working redirect
ruffsl May 1, 2023
15c6881
Simplify index.html
ruffsl May 1, 2023
141125f
Add helper redirect to simplify foxglove
ruffsl May 1, 2023
690edc8
Avoid hardcoding port number
ruffsl May 1, 2023
3afb045
Clean up comments
ruffsl May 1, 2023
5ed6852
Use header to compute redirect
ruffsl May 1, 2023
a1c9d87
Use shorthand placeholders
ruffsl May 3, 2023
4428a4d
Formatting
ruffsl May 3, 2023
396be37
Keep trailing slash
ruffsl May 4, 2023
2b0d9ca
Refactor matcher logic
ruffsl May 4, 2023
0a66df2
Split snippet into globals
ruffsl May 4, 2023
0f0d087
Update comments
ruffsl May 4, 2023
5cb672d
Add Placeholders
ruffsl May 5, 2023
bfc3224
Use tables to center
ruffsl May 5, 2023
27f961b
Use github markdown
ruffsl May 5, 2023
887bed4
Simplify vars
ruffsl May 5, 2023
4fe4c0b
Rename vars
ruffsl May 5, 2023
94a08af
Revert "Rename vars"
ruffsl May 5, 2023
e88681b
Add System Monitor
ruffsl May 5, 2023
7815091
Update headings
ruffsl May 5, 2023
f3acf06
Update layout
ruffsl May 5, 2023
7b2ba15
Update layout
ruffsl May 5, 2023
54255fe
Add Foxglove layout for Nav2
ruffsl May 7, 2023
5b1ed25
Symlink assets folder for web server
ruffsl May 7, 2023
658a460
Fetch Foxglove layout using layoutUrl
ruffsl May 7, 2023
19eaf42
Cleanup
ruffsl May 7, 2023
8f72374
Use fork to fetch Foxglove layout using layoutUrl
ruffsl May 10, 2023
85f51dd
Update Caddyfile to handle relative root
ruffsl May 11, 2023
67a59d6
Inject mobile view html tags
ruffsl May 11, 2023
611134e
Simplify Caddyfile
ruffsl May 11, 2023
abb3d18
Use snippet for apps
ruffsl May 11, 2023
76634f2
Simplify Caddyfile
ruffsl May 11, 2023
e67b8f0
Simplify Caddyfile
ruffsl May 11, 2023
7ed47ca
Build caddy using custom modules
ruffsl May 11, 2023
8ae87d4
Remove unused symlinks
ruffsl May 11, 2023
d24dd40
Add comments
ruffsl May 11, 2023
0c0e60c
Use environment and defined variables for config
ruffsl May 11, 2023
e1bbee6
Add FoxgloveUrl to vars
ruffsl May 11, 2023
40b36f3
Fix trailing slash for DataSourceUrl
ruffsl May 12, 2023
be80022
Use exec to run gzserver with xvfb
ruffsl May 12, 2023
a250c2b
Update redirect for foxglove
ruffsl May 12, 2023
d335685
Add redirect for foxglove
ruffsl May 12, 2023
1379e2e
Use web app manifest
ruffsl May 12, 2023
99fe0ce
Template manifest files
ruffsl May 12, 2023
a923f00
Add manifests for other web apps
ruffsl May 12, 2023
b7daa7e
Add shortcuts for Foxglove
ruffsl May 12, 2023
6c58dec
Format
ruffsl May 12, 2023
18f77c0
Update comments
ruffsl May 12, 2023
b630e36
Revert use of fork
ruffsl May 12, 2023
1d3985d
Remove debug directive
ruffsl May 12, 2023
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
122 changes: 122 additions & 0 deletions .devcontainer/caddy/Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Snippet for global matchers and variables
# to logically expression request conditions
# E.g. for conditionally changing redirects
(globals) {
# Use gzip compression for all responses
encode gzip

# Matcher for http request scheme. E.g. "http" or "https"
@http_scheme {
expression {http.request.scheme}=="https" || {header.X-Forwarded-Scheme}=="https"
}
# If any http scheme is "https", then use "wss"
vars @http_scheme WsScheme "wss"
# Else default to "ws"
vars WsScheme "ws"

# Matcher for forwarded request headers
@host_forwarded {
header X-Forwarded-Host *
}
# If http headers exists, then use them
vars @host_forwarded WsHost {header.X-Forwarded-Host}
# Else default to host in request
vars WsHost {http.request.hostport}

# Matcher for websocket connection upgrade requests
@websockets {
# Avoid case sensitivity issues when matching field values
# E.g. when values are rewritten by Codespace port forwarding
header_regexp Connection (?i)(Upgrade)
header Upgrade websocket
}
}

# Snippet for redirect with given URL queries values
# to simplify remote development with web apps
# 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}/"
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}"
}

# Snippet for dummy imports
(dummy) {
}

# Snippet for enabling mobile web app features
# to improve user experience on small screen devices
# E.g. for enabling fullscreen mode on iOS and Android
(mobile) {
# Match for directory redirects to index.html
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" />`
}
# Redirect relative handle_path'ed manifest.json to /manifests directory
redir /manifest.json /manifests{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
# Enable mobile web app features
import mobile
# Reverse proxy websockets to backend address
reverse_proxy @websockets {args.2}
# Import custom snippets
import {args.3} {args.0}
}
}

# Listen for http requests on port 8080
# regardless of hostname or domain address
# E.g. whatever Codespaces assigns to host
:8080 {
# Include global matchers and variables
import globals

# Handle main landing page
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
}
}

# Import app snippets for web apps
import app "/gzweb" "{$GZWEB_WS}/http/client" "localhost:9090" "dummy"
import app "/foxglove" "{$FOXGLOVE_WS}" "localhost:8765" "redirect"

# Handle glances web app
redir /glances /glances/
handle_path /glances/* {
import mobile
# Reverse proxy to glances backend
reverse_proxy * "localhost:61208"
}

# For debugging
# log {
# output file /var/log/caddy/server.log
# }
}
Loading