opendatacube / datacube-ows

Open Data Cube Open Web Services
Other
71 stars 37 forks source link

Add proxy fix header handling for X-Forwarded-For etc. #1085

Closed alexgleith closed 2 weeks ago

alexgleith commented 2 weeks ago

This is a low-risk and high-reward feature that adds another environment variable that turns on the "proxy_fix" middleware, which ensures the app understands what URLs it should return as part of the getCaps and other responses.

Tested in production for DE Pacific.


πŸ“š Documentation preview πŸ“š: https://datacube-ows--1085.org.readthedocs.build/en/1085/

codecov[bot] commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 63.63636% with 4 lines in your changes missing coverage. Please review.

Project coverage is 93.28%. Comparing base (5a0fbf4) to head (f298a2e). Report is 6 commits behind head on develop-1.9.

Files with missing lines Patch % Lines
datacube_ows/startup_utils.py 42.85% 4 Missing :warning:
Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/opendatacube/datacube-ows/pull/1085/graphs/tree.svg?width=650&height=150&src=pr&token=FWCMaSEoXd&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opendatacube)](https://app.codecov.io/gh/opendatacube/datacube-ows/pull/1085?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opendatacube) ```diff @@ Coverage Diff @@ ## develop-1.9 #1085 +/- ## =============================================== - Coverage 93.33% 93.28% -0.05% =============================================== Files 53 53 Lines 7032 7040 +8 =============================================== + Hits 6563 6567 +4 - Misses 469 473 +4 ``` | [Files with missing lines](https://app.codecov.io/gh/opendatacube/datacube-ows/pull/1085?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opendatacube) | Coverage Ξ” | | |---|---|---| | [datacube\_ows/feature\_info.py](https://app.codecov.io/gh/opendatacube/datacube-ows/pull/1085?src=pr&el=tree&filepath=datacube_ows%2Ffeature_info.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opendatacube#diff-ZGF0YWN1YmVfb3dzL2ZlYXR1cmVfaW5mby5weQ==) | `90.54% <100.00%> (ΓΈ)` | | | [datacube\_ows/ogc.py](https://app.codecov.io/gh/opendatacube/datacube-ows/pull/1085?src=pr&el=tree&filepath=datacube_ows%2Fogc.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opendatacube#diff-ZGF0YWN1YmVfb3dzL29nYy5weQ==) | `86.13% <100.00%> (+0.10%)` | :arrow_up: | | [datacube\_ows/startup\_utils.py](https://app.codecov.io/gh/opendatacube/datacube-ows/pull/1085?src=pr&el=tree&filepath=datacube_ows%2Fstartup_utils.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opendatacube#diff-ZGF0YWN1YmVfb3dzL3N0YXJ0dXBfdXRpbHMucHk=) | `90.32% <42.85%> (-2.25%)` | :arrow_down: |
pjonsson commented 1 week ago

@alexgleith if I understand your description, GetCapabilities will return broken results without this. Does this already work for the main branch, or should this commit also be merged there?

alexgleith commented 1 week ago

Hey @pjonsson this was merged into the main branch too.

pjonsson commented 1 week ago

@alexgleith are you sure about that? If I git grep PROXY_FIX on latest master, I get no hits.

alexgleith commented 1 week ago

@alexgleith are you sure about that?

Nope, not sure! I think it must have been the other fix about cache-control headers that was merged into both.

Happy to review a PR that adds this to the 1.8 branch.