Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proxy_uri_header=1 not working #19544

Open
NathanC opened this issue Jul 18, 2022 · 7 comments
Open

proxy_uri_header=1 not working #19544

NathanC opened this issue Jul 18, 2022 · 7 comments
Labels
Bug For errors / faults / flaws.

Comments

@NathanC
Copy link

NathanC commented Jul 18, 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 127.0.0.1:8080 {
		header_up X-Forwarded-Uri "/matomo"
	}
}

My config.ini.php settings are as follows:

[General]
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

tl;dr;

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?

@NathanC NathanC added the Potential Bug Something that might be a bug, but can't be reproduced (yet). label Jul 18, 2022
@sgiehl
Copy link
Member

sgiehl commented Jul 19, 2022

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.

@sgiehl sgiehl added this to the For Prioritization milestone Jul 19, 2022
@NathanC
Copy link
Author

NathanC commented Jul 19, 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
Copy link
Member

sgiehl commented Jul 20, 2022

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
Copy link

facing similar issue

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

@sgiehl sgiehl added Bug For errors / faults / flaws. and removed Potential Bug Something that might be a bug, but can't be reproduced (yet). labels Nov 9, 2022
@rupertbg
Copy link

@NathanC are you running Matomo in Docker? With Apache?

@viceice
Copy link

viceice commented Sep 14, 2023

Seeing same behavior when calling https://domain.test/matomo, it works when using https://domain.test/matomo/index.php

I'm using the apache version from bitnami1

Footnotes

  1. https://hub.docker.com/r/bitnami/matomo/

@viceice
Copy link

viceice commented Sep 14, 2023

It's also working when calling https://domain.test/matomo/ (with trailing slash)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws.
Projects
None yet
Development

No branches or pull requests

5 participants