Fix for Mixed Content Error on Flame Graph Download #75
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.
Fix for Mixed Content Error on Flame Graph Download
Problem
When attempting to download a flame graph SVG file over HTTPS, Chrome browser was blocking the download with the following error:
Root Cause
The nginx reverse proxy was not forwarding the necessary headers to inform the backend application (FastAPI/Gunicorn) that the original request was made over HTTPS. This caused the backend to potentially generate HTTP redirects or URLs instead of HTTPS ones.
Solution
Two files were updated to fix this issue:
1.
/deploy/https_nginx.confAdded proxy headers to all location blocks to preserve the original HTTPS protocol information:
These headers tell the backend:
2.
/src/gprofiler/run.shAdded the
--forwarded-allow-ips='*'flag to the gunicorn command line to make it trust and process the X-Forwarded-* headers:--forwarded-allow-ips='*'This tells Gunicorn/Uvicorn to trust the forwarded headers from the nginx proxy and use them when building URLs.
Deployment
After applying these changes:
Rebuild the Docker images:
cd deploy docker-compose build webappRestart the services:
docker-compose restart webapp docker-compose restart nginx # if nginx is in docker-composeOr if nginx is running separately:
Testing
To verify the fix:
Security Note
The
--forwarded-allow-ips='*'setting trusts all proxies. In a production environment with multiple proxy layers, you may want to restrict this to specific IP addresses or networks for better security.