integrate using reverse proxy#3
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts Explorer’s hosted configuration to support integration behind a reverse proxy by making the API base URL configurable via environment variables.
Changes:
- Switch
hosted/config.yamlto readserver.app.api_base_urlfromAPI_BASE_URL(allowingnullto register routes at/). - Add reverse-proxy-related environment variables to
docker-compose.ymlto populateAPI_BASE_URL. - Document reverse-proxy env vars in
.env.example.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| hosted/config.yaml | Makes api_base_url configurable via API_BASE_URL for reverse-proxy setups. |
| docker-compose.yml | Adds env wiring intended to compute/pass API_BASE_URL into the Explorer container. |
| .env.example | Adds example reverse-proxy environment variables for local integration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - DEFAULT_API_BASE_URL=${PROXY_TRANSFER_PROTOCOL}://${PROXY_API_DOMAIN}/cellxgene/ | ||
| - API_BASE_URL=${PROXY_API_BASE_URL:-DEFAULT_API_BASE_URL} |
| PROXY_TRANSFER_PROTOCOL=https # for outside container | ||
| PROXY_API_DOMAIN=explorer.corporanet.local:5500 # for outside container |
| # ${TRANSFER_PROTOCOL}://${API_DOMAIN}/cellxgene/: Flask registers all API routes under a specific prefix | ||
| # null: Flask registers routes at /, so urls (e.g., /e/<dataset>/...) match correctly | ||
| # api_base_url: ${TRANSFER_PROTOCOL}://${API_DOMAIN}/cellxgene/ | ||
| api_base_url: ${API_BASE_URL} | ||
| web_base_url: ${TRANSFER_PROTOCOL}://${WEB_DOMAIN}/ |
There was a problem hiding this comment.
API_BASE_URL is set in docker-compose.yml, thus it should be available in the container.
| - RESTART_ON_FAILURE=yes | ||
| - DEV_MODE_COOKIES=1 | ||
| - IS_DOCKER_DEV=yes # This skips some unit tests. | ||
| - API_BASE_URL=${PROXY_API_BASE_URL:-${PROXY_TRANSFER_PROTOCOL}://${PROXY_API_DOMAIN}/cellxgene/} |
There was a problem hiding this comment.
Does the PROXY_TRANSFER_PROTOCOL and PROXY_API_DOMAIN come from the .env file?
There was a problem hiding this comment.
Yes, they come from the .env file.
| # ${TRANSFER_PROTOCOL}://${API_DOMAIN}/cellxgene/: Flask registers all API routes under a specific prefix | ||
| # null: Flask registers routes at /, so urls (e.g., /e/<dataset>/...) match correctly | ||
| # api_base_url: ${TRANSFER_PROTOCOL}://${API_DOMAIN}/cellxgene/ | ||
| api_base_url: ${API_BASE_URL} |
There was a problem hiding this comment.
I'm confused about what API_BASE_URL will actually be when running in different environments. It seems to be overwritten by the docker-compose
There was a problem hiding this comment.
Thank you for your comment, I think the environment variable names cause some confusion, thus I have updated a bit to make it clearer.
(Below is based on the updated scripts)
If we use reverse proxy:
+ We set PROXY_API_BASE_URL=null in .env file
+ In docker-compose.yml, API_BASE_URL=${PROXY_API_BASE_URL} # null
+ Then in config.yaml, api_base_url: ${API_BASE_URL} # null
If we do not use reverse proxy (i.e., it is as the default):
+ We do not set PROXY_API_BASE_URL in .env file
+ In docker-compose.yml, API_BASE_URL=${TRANSFER_PROTOCOL}://${API_DOMAIN}/cellxgene/
+ Then in config.yaml, api_base_url: ${API_BASE_URL}
For integrating Portal and Explorer using reverse proxy