Repository navigation
Serve the web client with nginx and proxy the API - #22
Merged
Merged
Conversation
…rigin `vite preview` is not meant for production and kept a ~90 MB Node process plus a full web-client checkout and node_modules on the instance. nginx now serves the CI-built files on port 4173 and proxies /auth, /api, /ws, /hub and /health to cloud-services, so the browser makes same-origin requests: no CORS, and port 8080 no longer has to be open to the internet. The bundle is now built with an empty API URL (the page origin) unless the WEB_API_BASE_URL repository variable is set. The first deploy installs nginx if it is missing and disables the old `frontend` service. Co-Authored-By: Claude Opus 5.5 <[email protected]>
2 of 3 tasks
Owner
|
lgtm |
2 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
vite previewon port 4173. It serves the CI-built files from/var/www/hyperloop-guiand proxies/auth,/api,/ws,/huband/healthto cloud-services at127.0.0.1:8080(seedeploy/nginx/hyperloop-gui.conf).ERR_CONNECTION_TIMED_OUTon view-only login at98.93.47.19:4173.WEB_API_BASE_URLis set. This also works whengui.cornellhyperloop.comis proxied to :4173.node_modules./assets/*files are cached for a year, andindex.htmlis revalidated on every load. gzip is on. Request bodies can be up to 25 MB, because the flash request carries the firmware base64-encoded.What the first deploy does on EC2
/var/www/hyperloop-gui, installs the site config and runsnginx -t.frontend(vite preview) service, then starts or reloads nginx. Expect a second or two of downtime on this first deploy only.These are left in place and can be deleted by hand later:
/home/ubuntu/web-clientand/etc/systemd/system/frontend.service.Notes
api.cornellhyperloop.com, or connect through nginx atws://<host>:4173/hub.X-Forwarded-Forfrom 127.0.0.1 by default, so the backend still sees each browser's real IP and the per-IP login limits keep working. LeaveTRUST_PROXY_HEADERS=false.Stack
This PR is based on #21 (
feat/ci-built-web-client). Merge it into that branch first, then merge #21 into main, so there is a single deploy. CI test jobs only run on PRs into main, and this PR doesn't change any service code.Test plan
nginx -tpasses in annginx:stablecontainer.127.0.0.1:8080resolves as it does on EC2./returns 200 withCache-Control: no-cache,/devicesreturns the app shell, and a missing asset returns 404.immutablecaching.POST /auth/login-viewerreturns 200,/auth/mereports the viewer role,/api/hubsreturns 200, and a viewer restart command returns 403./ws/clientand/hubwebsocket upgrades return 101.systemctl is-active nginxreports active,curl -s localhost:4173/healthresponds, and view-only login works from the browser athttp://98.93.47.19:4173.🤖 Generated with Claude Code