Wrong host name

Hi all,
I have a piwik installation on an Ubuntu server (12.04), with PHP5.3 and Varnish. Everything works fine since last update (from 2.0.3 to 2.1) but now the home page has no Piwik logo because of the img src is http://myip/public_html/plugins/Morpheus/images/logo.svg instead of http://www.whatisshouldbe.com/public_html/plugins/Morpheus/images/logo.svg
Then, when I try to login, the result is a page not found because of a redirection on my ip in that moment or an Error: Form security failed… sometimes the first, some times the other… apparently with no reason.
Another strange thing is that when the first case happens, a back button or write the correct hostname in place of my current ip address opens Piwik correctly… so the login works, but I have a wrong redirection.

I suppose is something regarding varnish and the new Piwik version…

Can someone help me? Many thanks

This is my config.ini.php (where www.XXXX.it is the right site name that is now replaced with my current ip):


; <?php exit; ?> DO NOT REMOVE THIS LINE
; file automatically generated or modified by Piwik; you can manually override the default values in global.ini.php by redefining them in this file.
[database]
host = "127.0.0.1"
username = "XXXX"
password = "XXXX"
dbname = "XXXX"
tables_prefix = "piwik_"
charset = "utf8"

[General]
trusted_hosts[] = "www.XXXX.it"
proxy_client_headers[] = "HTTP_X_FORWARDED_FOR"
proxy_host_headers[] = "HTTP_X_FORWARDED_FOR"
salt = "XXXX"

[Plugins]
Plugins[] = "CorePluginsAdmin"
Plugins[] = "CoreAdminHome"
Plugins[] = "CoreHome"
Plugins[] = "CoreVisualizations"
Plugins[] = "Proxy"
Plugins[] = "API"
Plugins[] = "ExamplePlugin"
Plugins[] = "Widgetize"
Plugins[] = "Transitions"
Plugins[] = "LanguagesManager"
Plugins[] = "Actions"
Plugins[] = "Dashboard"
Plugins[] = "MultiSites"
Plugins[] = "Referrers"
Plugins[] = "UserSettings"
Plugins[] = "Goals"
Plugins[] = "SEO"
Plugins[] = "Events"
Plugins[] = "UserCountry"
Plugins[] = "VisitsSummary"
Plugins[] = "VisitFrequency"
Plugins[] = "VisitTime"
Plugins[] = "VisitorInterest"
Plugins[] = "ExampleAPI"
Plugins[] = "ExampleRssWidget"
Plugins[] = "Provider"
Plugins[] = "Feedback"
Plugins[] = "Login"
Plugins[] = "UsersManager"
Plugins[] = "SitesManager"
Plugins[] = "Installation"
Plugins[] = "CoreUpdater"
Plugins[] = "CoreConsole"
Plugins[] = "ScheduledReports"
Plugins[] = "UserCountryMap"
Plugins[] = "Live"
Plugins[] = "CustomVariables"
Plugins[] = "PrivacyManager"
Plugins[] = "ImageGraph"
Plugins[] = "Annotations"
Plugins[] = "MobileMessaging"
Plugins[] = "Overlay"
Plugins[] = "SegmentEditor"
Plugins[] = "Morpheus"
Plugins[] = "Zeitgeist"

[PluginsInstalled]
PluginsInstalled[] = "Login"
PluginsInstalled[] = "CoreAdminHome"
PluginsInstalled[] = "UsersManager"
PluginsInstalled[] = "SitesManager"
PluginsInstalled[] = "Installation"
PluginsInstalled[] = "CorePluginsAdmin"
PluginsInstalled[] = "CoreHome"
PluginsInstalled[] = "Proxy"
PluginsInstalled[] = "API"
PluginsInstalled[] = "Widgetize"
PluginsInstalled[] = "LanguagesManager"
PluginsInstalled[] = "Actions"
PluginsInstalled[] = "Dashboard"
PluginsInstalled[] = "MultiSites"
PluginsInstalled[] = "UserSettings"
PluginsInstalled[] = "Goals"
PluginsInstalled[] = "SEO"
PluginsInstalled[] = "UserCountry"
PluginsInstalled[] = "VisitsSummary"
PluginsInstalled[] = "VisitFrequency"
PluginsInstalled[] = "VisitTime"
PluginsInstalled[] = "VisitorInterest"
PluginsInstalled[] = "ExampleAPI"
PluginsInstalled[] = "ExamplePlugin"
PluginsInstalled[] = "ExampleRssWidget"
PluginsInstalled[] = "Provider"
PluginsInstalled[] = "Feedback"
PluginsInstalled[] = "CoreUpdater"
PluginsInstalled[] = "UserCountryMap"
PluginsInstalled[] = "Live"
PluginsInstalled[] = "CustomVariables"
PluginsInstalled[] = "PrivacyManager"
PluginsInstalled[] = "ImageGraph"
PluginsInstalled[] = "DoNotTrack"
PluginsInstalled[] = "Transitions"
PluginsInstalled[] = "Annotations"
PluginsInstalled[] = "MobileMessaging"
PluginsInstalled[] = "Overlay"
PluginsInstalled[] = "CoreVisualizations"
PluginsInstalled[] = "Referrers"
PluginsInstalled[] = "Events"
PluginsInstalled[] = "CoreConsole"
PluginsInstalled[] = "ScheduledReports"
PluginsInstalled[] = "SegmentEditor"
PluginsInstalled[] = "Morpheus"
PluginsInstalled[] = "Zeitgeist"

[Plugins_Tracker]
Plugins_Tracker[] = "Provider"
Plugins_Tracker[] = "Goals"
Plugins_Tracker[] = "PrivacyManager"
Plugins_Tracker[] = "UserCountry"
Plugins_Tracker[] = "UsersManager"
Plugins_Tracker[] = "SitesManager"
Plugins_Tracker[] = "Login"


PLease check, if there are any redirections active (e.g. htaccess in the piwik, or piwik’a parent folder). If you are behind a proxy, please configure the proxy in the Piwik config. Piwik Backend may not be cached (by varnish), otherwise, form security will fail.

http://piwik.org/faq/how-to-install/#faq_98

It seems, you uploaded the image while being on another host name. Please reupload your logo, when you entered Piwik on the correct domain.

Peter, first of all thanks for the quick reply.

This part:

proxy_client_headers[] = "HTTP_X_FORWARDED_FOR"
proxy_host_headers[] = “HTTP_X_FORWARDED_FOR”

already is my proxy configuration (plus something else in varnish and apache), and, as I’ve mentioned before, everything was fine with varnish and everything before the 2.1 Piwik upgrade. After upgrading to 2.0.3 I’ve made some modification because I had 127.0.0.1 in my statistics as ip for every visitor, but after that part in Piwik configuration and varnish configuration I had everything fine. Now this…
No .htaccess in piwik directory, and however I have not modified any .htaccess in the meanwhile.
The logo problem is not really a problem, however is the normal Piwik logo, no customizations at all. I mentioned it because I suppose it’s all related: redirect after login to my own ip, src path of the logo image with my ip… my ip should not be there at all, but I should have the www.XXXXX.it I specified in my settings.
Thanks again to everyone

I’ve followed this thread 301 Moved Permanently
and made everything in it… but without success (I can successfully login through android app too).

Ugly (very ugly) workaround I found:

in file core/url.php commented line 335


        $config = Config::getInstance()->General;
        if(isset($config['proxy_host_headers'])) {
        //    $hostHeaders = $config['proxy_host_headers'];
        }

So my problem is surely varnish/proxy related… I hope someone can figure out this, in the meanwhile I have a workaround. Many thanks to all

I’m very sorry… finally I find out my problem, a wrong configuration.

In my Piwik configuration I had:


proxy_client_headers[] = "HTTP_X_FORWARDED_FOR"
proxy_host_headers[] = "HTTP_X_FORWARDED_FOR"

but it should be:


proxy_client_headers[] = "HTTP_X_FORWARDED_FOR"
proxy_host_headers[] = "HTTP_X_FORWARDED_HOST"

Many thanks, I hope my mistake can be useful for someone.

Since this post was helpful to me, I thought I’d pass along my own configuration for getting Matomo to work with HAProxy. I too was seeing the weird redirection of the Matomo logo png file to my public IP address. I had to make the following changes:

I set the Matomo proxy settings set to the following:

proxy_client_headers = “HTTP_X_FORWARDED_FOR”
proxy_host_headers = “HTTP_X_FORWARDED_HOST”

I needed to set my HA proxy option to forwardfor. E.g.:

option forwardfor

This is in the backend section.
Initially I had the option set to this:

option forwardfor header X-Real-Originating-IP

but it didn’t work. The simple option forwardfor works with Matomo’s “HTTP_X_FORWARDED_FOR” setting.