@evrard-c opened this Issue on November 1st 2016

When a user access to the site by using Opera Mini, Piwik displays a wrong location, this location always be "Norway" or "EU". This wrong location occur because Opera Mini is a proxy browser, so the location indicated by Piwik it's the location of Opera Mini's server not the user location.
Piwik use the IP adress of Opera Mini server instead of the true IP adress of the user.
This can be fixed by using the real IP of the user like Opera explanes it in this page when talking about "X-Forwarded-For"

It might be better to also have the real Opera Mini icon instead of the same as Opera because they don't have the same icon, each has its own.

Yes, i know that it looks like an Opera Mini's advocacy, but when you work on a project in a country where Opera Mini reach 85% of the traffic, you don't really have choice. ;)

@sgiehl commented on November 2nd 2016 Member

It might be better to also have the real Opera Mini icon instead of the same as Opera because they don't have the same icon, each has its own.

If Opera Next is detected it should use the icon https://github.com/piwik/piwik/blob/3.x-dev/plugins/DevicesDetection/images/browsers/ON.gif Isn't that correct?

@evrard-c commented on November 3rd 2016

Ooh, not really
That's the icon for "Opera Next", but I was talking about "Opera Mini"

@sgiehl commented on November 3rd 2016 Member

Ok. Opera and Opera Mini use icons that are almost identical. This one ise used for Opera Mini and may need an update: https://github.com/piwik/piwik/blob/3.x-dev/plugins/DevicesDetection/images/browsers/OI.gif

@evrard-c commented on November 4th 2016

Yeah it will need an update and it will also be better if the right IP of the visitor using Opera Mini is used to identify his right location instead of always indicate the Opera Mini's server location. This dysfunction creat big statistics errors for countries where Opera Mini is largely used.

@mattab commented on November 11th 2016 Owner

@evrard-c Maybe Opera Mini still forward the original user IP in another HTTP header? we have similar cases already see: http://piwik.org/faq/how-to-install/faq_98/

if you have access to a opera mini please visit a page test.php with <?php var_dump($_SERVER); ?> and post here the output you see in opera mini?

@evrard-c commented on November 13th 2016

@mattab as you asked, I created a test page with <?php var_dump($_SERVER); ?> and bellow it's the output of the test page as displayed in Opera Mini.

To identify the location of the visitor, Piwik uses the IP in ["REMOTE_ADDR"] unfortunatelly, this is the IP of the Opera Mini's server. In the Dev documentation Opera recommand to use the IP in ["HTTP_X_FORWARDED_FOR"] to get the IP of the visitor, So this one can give the true location of the visitor instead of giving the location of the Opera Mini's server.

array(45) { ["PATH"]=> string(29) "/sbin:/usr/sbin:/bin:/usr/bin" ["PWD"]=> string(25) "/usr/local/cpanel/cgi-sys" ["SHLVL"]=> string(1) "0" ["PHP_FCGI_MAX_REQUESTS"]=> string(4) "5000" ["SCRIPT_NAME"]=> string(11) "/test-2.php" ["REQUEST_URI"]=> string(11) "/test-2.php" ["QUERY_STRING"]=> string(0) "" ["REQUEST_METHOD"]=> string(3) "GET" ["SERVER_PROTOCOL"]=> string(8) "HTTP/1.1" ["GATEWAY_INTERFACE"]=> string(7) "CGI/1.1" ["REMOTE_PORT"]=> string(5) "49823" ["SCRIPT_FILENAME"]=> string(35) "/home/mysite1/public_html/test-2.php" ["SERVER_ADMIN"]=> string(18) "webmaster<a class='mention' href='https://github.com/mysite'>@mysite</a>.cd" ["CONTEXT_DOCUMENT_ROOT"]=> string(24) "/home/site1/public_html" ["CONTEXT_PREFIX"]=> string(0) "" ["REQUEST_SCHEME"]=> string(5) "https" ["DOCUMENT_ROOT"]=> string(24) "/home/mysite1/public_html" ["REMOTE_ADDR"]=> string(14) "82.145.219.168" ["SERVER_PORT"]=> string(3) "443" ["SERVER_ADDR"]=> string(13) "23.229.143.84" ["SERVER_NAME"]=> string(12) "www.mysite.cd" ["SERVER_SOFTWARE"]=> string(13) "Apache/2.4.23" ["SERVER_SIGNATURE"]=> string(0) "" ["LD_LIBRARY_PATH"]=> string(21) "/usr/local/apache/lib" ["HTTP_X_FORWARDED_FOR"]=> string(14) "169.255.204.14" ["HTTP_X_OPERAMINI_PHONE"]=> string(9) "Android #" ["HTTP_FORWARDED"]=> string(26) "for="169.255.204.14:11842"" ["HTTP_X_OPERAMINI_PHONE_UA"]=> string(145) "Mozilla/5.0 (Linux; Android 4.4.4; SM-J100H Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36" ["HTTP_X_OPERAMINI_FEATURES"]=> string(94) "advanced, httpping, pingback, routing, viewport, folding, camera, download, touch, file_system" ["HTTP_DEVICE_STOCK_UA"]=> string(145) "Mozilla/5.0 (Linux; Android 4.4.4; SM-J100H Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36" ["HTTP_CONNECTION"]=> string(5) "close" ["HTTP_CACHE_CONTROL"]=> string(8) "no-cache" ["HTTP_COOKIE"]=> string(98) "_pk_id.1.761e=9ea9373d14368c08.1477603572.2.1478986736.1478986736.; _ga=GA1.2.966386884.1476233539" ["HTTP_ACCEPT_ENCODING"]=> string(13) "gzip, deflate" ["HTTP_ACCEPT_LANGUAGE"]=> string(11) "fr,en;q=0.9" ["HTTP_ACCEPT"]=> string(129) "text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1" ["HTTP_HOST"]=> string(12) "www.mysite.cd" ["HTTP_USER_AGENT"]=> string(87) "Opera/9.80 (Android; Opera Mini/12.0.1987/37.9072; U; fr) Presto/2.12.423 Version/12.16" ["SSL_TLS_SNI"]=> string(12) "www.mysite.cd" ["HTTPS"]=> string(2) "on" ["UNIQUE_ID"]=> string(24) "WChzKTI<a class='mention' href='https://github.com/oWMAADctokcAAABA'>@oWMAADctokcAAABA</a>" ["FCGI_ROLE"]=> string(9) "RESPONDER" ["PHP_SELF"]=> string(11) "/test-2.php" ["REQUEST_TIME_FLOAT"]=> float(1479045929.6347) ["REQUEST_TIME"]=> int(1479045929) }

@mattab commented on December 5th 2016 Owner

Thanks @evrard-c for the details.

In the Dev documentation Opera recommand to use the IP in ["HTTP_X_FORWARDED_FOR"] to get the IP of the visitor, So this one can give the true location of the visitor instead of giving the location of the Opera Mini's server.

Do you maybe have a link to this doc?

Note: currently you can configure Piwik to read the HTTP_X_FORWARDED_FOR IP instead of REMOTE_ADDR, as documented in: http://piwik.org/faq/how-to-install/faq_98/ - but this will apply to all visits... so this does not work too well when only opera mini users will set this header.

Once confirmed then, it sounds like we will need to add a "Special case" handling for Opera mini users, and always read HTTP_X_FORWARDED_FOR for these users.

@evrard-c commented on December 12th 2016

@mattab ,
I'm glad that you understand the problem
This is the link to the doc where Opera explains details about HTTP Headers in Opera Mini : https://dev.opera.com/articles/opera-mini-request-headers/
I also think that the best way to correct it, will be to add a "Special case" handling for Opera Mini users

@robocoder commented on February 12th 2018 Contributor

Or add 195.189.142.0/23 to proxy_ips?

Powered by GitHub Issue Mirror