Fix QGIS Server service URL calculation when X-Forwarded-Proto header has multiple values#64942
Fix QGIS Server service URL calculation when X-Forwarded-Proto header has multiple values#64942jgrocha wants to merge 3 commits intoqgis:masterfrom
Conversation
🪟 Windows Qt6 buildsDownload Windows Qt6 builds of this PR for testing. 🍎 MacOS Qt6 buildsDownload MacOS Qt6 builds of this PR for testing. |
|
The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
|
|
The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
|
|
While we hate to see this happen, this PR has been automatically closed because it has not had any activity in the last 21 days. If this pull request should be reconsidered, please follow the guidelines in the previous comment and reopen this pull request. Or, if you have any further questions, just ask! We love to help, and if there's anything the QGIS project can do to help push this PR forward please let us know how we can assist. |
Description
This PR does 3 different (little) things. For each feature, there is only one piece of code changed. Comments are welcome regarding each feature.
There are 3 more formatting changes in this PR. They were produced byscripts/astyle.sh.I was still using
scripts/astyle.shon files outsidesrc/core. So sorry! I've updated the PR usingclang-formatfor files undersrc/server.1. Fix #64940
Support for protocol list in X-Forwarded-Proto header. Now it is possible to receive a X-Forwarded-Proto header like:
X-Forwarded-Proto: https, https, HTTPS.2. Read QGIS_SERVER_SERVICE_URL environment variable in every request
Only the QGIS_PROJECT_FILE file is read on every request. This variable can be set in a rewrite rule, for example, for every request. Other environment variables are read only when the server starts.
This PR also reads QGIS_SERVER_SERVICE_URL environment variable in every request, giving more flexibility to set it, when headers are not enough. This PR was motivated by this limitation: when the service URL is not being properly computed, we must provide a way to force it.
For example, with this PR we can define something like this on Apache (example with mod_rewrite):
This rewrite rule defines two environment variables on every request:
For a request like this:
https://osgeo.local/postgresql/5363_carttop1_coimbra_20250401/public/testewfs/cgi-bin/qgis_mapserv.fcgi, the variables will be defined as:If we change the project being served, both QGIS_SERVER_SERVICE_URL and QGIS_PROJECT_FILE are set automatically.
3. Log headers
Before this PR, headers could be logged only on a debug version. On a quality/production environment, it is not easy to compile and run a debug version to check the atual headers received.
This PR removes the header logging on debug versions and make it happen on release versions, depending on QGIS_SERVER_LOG_LEVEL variable.