Repository navigation
Conversation
9 of 13 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
The frontend image ran yarn run
start:demo, which iswebpack-dev-serverin development mode, compiled at every pod start. That made it impractical to put behind a TLS reverse proxy: the dev server rejected the proxy's hostname,api.jshard-codedhttp://, and the browser had to reach the backend NodePort directly. Customers worked around it with scripts that patch the running pods.This PR replaces the dev server with a production build served by an unprivileged nginx, and makes API calls same-origin.
Changes
frontend/Dockerfile,frontend/nginx/*): a two-stage build with the build stage on$BUILDPLATFORMand a finalnginx-unprivilegedimage./api/toBACKEND_URL, and sets security headers.DEMO_PORTand runs as an arbitrary UID with a read-only root filesystem (writes only to/tmp).entrypoint.shvalidates its env values before rendering the config.TRUSTED_PROXY_CIDRSmakes nginx take the real client address fromX-Forwarded-Forfor listed proxies.api.js,host.jsxremoved): baseURL is/api.start:demoproxies/apito the Flask backend for local development.webpack.standalone.config.js): no eval source maps in production builds, so the CSP needs no unsafe-eval. The bundle drops from about 10 MB to 1.8 MB.__init__.py): newTRUSTED_PROXY_COUNT(default 0) enables werkzeugProxyFix. Behind a proxy, the/auth/loginrate limit (5 per minute) is then per client rather than shared by everyone.test_trusted_proxy.pyfor the backend andapi.test.jsfor the frontend.Compatibility
DEMO_PORT,securityContextand Service nameui-backend-entrypoint.REACT_APP_FLASK_PORT). Those patches must be removed.serviceType,trustedProxyCIDRs, ClusterIP backend default) are in a separate PR in splunk-connect-for-snmp.