Correct URL generation (for assets) when running Matomo behind a reverse proxy on a sub path.
Incorrect URL generation since some reverse proxies such as traefik provide the URI using HTTP_X_FORWARDED_PREFIX rather than HTTP_X_FORWARDED_URI.
Extend the URL generation to also consider HTTP_X_FORWARDED_PREFIX if set in addition to HTTP_X_FORWARDED_URI as shown here:
Thanks for reporting this @andremartin . I wonder if we should maybe support also different flags like when
proxy_uri_header=1(for backwards compatibility) still use
Then we also allow configuring
HTTP_X_FORWARDED_PREFIX as a value like
proxy_uri_header="HTTP_X_FORWARDED_PREFIX" proxy_uri_header="HTTP_X_FORWARDED_URI" proxy_uri_header="..."
Basically, when it's non numeric then we assume a user configured the name of the header.
I'm just meaning this approach be slightly more secure in that the host header cannot be simply set by anyone. By only allowing a specific header eg the user could make sure to not allow this header to be overwritten etc.