我在server1 (https://server1.com)上安装了一个matomo实例,它工作得很好。
我尝试使用nginx代理在一个子目录中访问server1:https://server2.com/matomo/,然后我得到了日志表单。有一次,我按了login,我没有进入matomo,但我得到了https://server2.com/
想要:
https://server02.com/matomo/ (Server1.com的代理) ->登录-> https://server02.com/matomo/ (已登录)
我得到的是:
https://server02.com/matomo/ (server1.com的代理) ->登录-> https://server02.com/ (已登录到matomo,但url错误)。
我必须将url编辑为:https://server02.com/matomo/
我的配置:
config.ini.php (matomo):
[general]
proxy_client_headers[] = HTTP_X_FORWARDED_FOR
proxy_host_headers[] = HTTP_X_FORWARDED_HOST
nginx.conf:
location /matomo/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass https://server1.com/;
proxy_set_header Referer $http_referer;
proxy_set_header X-Forwarded-Proto https;
proxy_buffering off;
}
发布于 2020-01-20 14:00:36
如果你在https://matomo.org/faq/how-to-install/faq_98/上查看:
如果Matomo位于反向代理之后并安装在子路径中
如果您在具有不同路径的反向代理后面使用Matomo,例如重写^ /piwik /(.*)$ /$1 break;(在nginx.conf中,当Matomo安装在/piwik路径中时),您需要:
1)配置您的web服务器以提供报头HTTP_X_FORWARDED_URI。例如,在NGINX上,当Matomo安装在/piwik路径中时,您可以在nginx.conf中设置proxy_set_header X-Forwarded-Uri /piwik;。
2)配置Matomo读取该HTTP_X_FORWARDED_URI,构造正确的URL。在Matomo config/config.ini.php的General部分中添加:
[General]
; Use the header HTTP_X_FORWARDED_URI to construct the current script name
proxy_uri_header = 1
https://stackoverflow.com/questions/59799971
复制相似问题