@NathanC opened this Issue on July 18th 2022

Expected Behavior

Reverse proxying with a path prefix should cause the site to respect when proxy_uri_header = 1 is set.

Current Behavior

my-domain.example.com/matomo proxies successfully, but immediately gets redirected to my-domain.example.com/index.php. The proxy prefix isn't working correctly.

I have matomo behind a reverse proxy on the /matamo path. I'm using the Caddy webserver, and I'm setting the X-Forwarded-Uri header. I've tested with a script, and the header is correctly getting sent during proxying.

handle_path /matomo {
    reverse_proxy {
        header_up X-Forwarded-Uri "/matomo"

My config.ini.php settings are as follows:

proxy_client_headers[] = "HTTP_X_FORWARDED_FOR"
proxy_host_headers[] = "HTTP_X_FORWARDED_HOST"
trusted_hosts[] = "my-domain.example.com"
force_ssl = 1
assume_secure_protocol = 1
; Use the header HTTP_X_FORWARDED_URI to construct the current script name
proxy_uri_header = 1

From all the guides I've fo

Expected behavior

I would expect proxy_uri_header = 1 to be respected, and internal links to be prefixed by /matomo by the Matomo.

My Environment

Matomo version: 4.10.1
MySQL version: 10.8.3-MariaDB-1:10.8.3+maria~jammy
PHP version: 8.0.21


proxy_uri_header = 1 doesn't seem to be working.

Any idea what's going on? Is there some way I can confirm that X-Forwarded-Uri is reaching the proper parser in Matomo? Anything else I should try?

@sgiehl commented on July 19th 2022 Member

Hi @NathanC
Thanks for creating this issue. I have actually not yet used this special option. So I'm not able to say if that feature actually worked before or not. Unfortunately I'm currently a bit short in time and have no possibility to create a similar set up in order to check this. Our product team will at some point plan in some time to check that in detail. But that might take some time, as there is stuff with higher priority.
In the meantime you could try to get some help on our forums. Maybe someone else already had a similar issue there and can help you.

@NathanC commented on July 19th 2022

I found a workaround. It turns out the issue only appears if I go directly to mysite/matomo, which causes it to redirect to mysite/index.php. If I go to mysite/matomo/index.php then it works properly.

My guess is that whatever does the redirect from the web root doesn't respect the proxy_uri_header flag like it should.

@sgiehl commented on July 20th 2022 Member

Our scripts should only try to redirect to index.php?module=..., without any folder or domain, so the browser should use the current url and path. Are you able to see the details of the redirecting request in the developer tools of your browser? Maybe that helps to identify the source.

@nikksnegi commented on September 8th 2022

facing similar issue

config,ini.php is perfect .
is there any way to give path "/matomo"

Powered by GitHub Issue Mirror