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
Apache Reverse Proxy Support #647
Comments
Attachment: |
Duplicates #466. Thanks for the patch, however, it is the responsibility of the reverse proxy to make it transparent for the web site/web application because Piwik doesn’t know if it’s behind one or more reverse proxies, or none at all. For Apache, I suggest using mod_proxy_html (which works now without code changes). Java System Web Proxy Server also takes the URL remapping approach (i.e., content URL rewriting). |
vipsoft I agree with you that this seems like a bug in the reverse proxy configuration. However if there is a quick fix as the one provided might be worth considering? My question would be: how other softwares like Wordpress or Drupal deal with this problem? javalexG, can you please quickly research and let us know? thanks |
Thank you for your answer, vipsoft! Anyway, my patch described above is based on solutions for other PHP-based tools installed behind a reverse proxy (sorry, I can’t find links to them anymore). Another (smart) solution is provided by Typo3 (v4.2) and is described here (with a link to bugtracker in a red box): http://www.henningpingel.de/TYPO3-Backend-Via-SSL-Proxy.124.0.html?&L=0 |
can you please find a link for your source (either wordpress, or typo3, drupal…) and a patch? we would like to add this support but want to get it right which means copy what other softwares did :) |
There's a simple solution: let the admin set the host or better an URL. I use Apache Roller in a reverse proxy situation. In Roller you can set an absolute URL for your application in the configuration dialogue, which replaces every automatic determined hostname/URL like the above mentioned (HTTP_HOST). If there's no absolute URL set, Roller uses HTTP_HOST. |
Replying to rafaelo: |
If I install Piwik behind a reverse proxy, I get some problems with the images and javascript URLs created by the tool. Instead of http://piwik.my-domain.com/… (public URL) I get http://piwik.local_network/ (internal URL) generated in front end.
The problem occures with Piwik versions 0.2.32 and 0.2.33.
For configuring reverse proxy I use apache mod_proxy module and this command in VHost configuration on public accessable host:
```
ProxyPass / http://piwik.local_network/
ProxyPassReverse / http://piwik.local_network/
```
and using own VHost on internal server.
Well, the cause is: with this type of installation the`
$SERVER[‘HTTP_HOST’]`variable contains ’piwik.localnetwork’ and not the real host name, which should be like ‘piwik.my-domain.com’.
The (proposed and working) solution is:
1. change lines 114-ff. in core/Url.php as following:
instead of
```
if(isset($SERVER[‘HTTP_HOST’]))
{
$url .= $_SERVER[’HTTPHOST’];
}
else
{
$url .= ‘unknown’;
}
```
use this one:
```
if(isset($SERVER[‘HTTP_X_FORWARDED_HOST’]))
{
$url .= $SERVER[‘HTTP_X_FORWARDED_HOST’];
}
elseif(isset($SERVER[’HTTPHOST’]))
{
$url .= $SERVER[’HTTPHOST’];
}
else
{
$url .= ‘unknown’;
}
```
1. Replace line 181-ff. in plugins/Login/controller.php as following:
after
```
$piwikHost = $SERVER[’HTTPHOST’];
```
add
```
if(isset($SERVER[‘HTTP_X_FORWARDED_HOST’]))
{
$piwikHost = $SERVER[’HTTP_XFORWARDEDHOST’];
}
```
That’s all.
PS:
Patched files are attached.
The text was updated successfully, but these errors were encountered: