matomo-org / matomo-org/docker
GeoIP issue in matomo image
- Dominant language
- Shell
- Stars
- 1k
- Forks
- 384
- PR merge metrics
- No merged PRs in 30d
Description
I have a problem.
I have 3 images.
1- Matomo:5.2.0
2- MariaDB:latest
3- Nginx:latest
This is the docker-compose:
`services:
matomoDb:
image: mariadb:latest
command: --max-allowed-packet=64MB
restart: always
ports:
- "3306:3306"
volumes:
- matomoDb:/var/lib/mysql:Z
env_file:
- db.env
networks:
- custom_network
matomo:
build:
context: .
dockerfile: Dockerfile
image: matomo-geoip:latest
restart: always
links:
- matomoDb
volumes:
- matomo:/var/www/html:z
networks:
- custom_network
matomoWeb:
image: nginx:latest
restart: always
volumes:
- matomo:/var/www/html:z,ro
- ./default.conf:/etc/nginx/conf.d/default.conf:z
ports:
- "8082:80"
networks:
- custom_network # Custom network for communication with other services
volumes:
matomoDb:
matomo:
networks:
custom_network:
driver: bridge`
This is default.conf
`
upstream backend {
server matomo:9000; # Ensure the port is specified here
}
server {
listen 80;
root /var/www/html/;
index index.php index.html index.htm;
# Forward the real client IP and other necessary headers
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
fastcgi_pass backend;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# Forward client IP and real IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
`
After I set matomo up in the admin page, I go to
Settings → System → Geolocation, then I download the GeoIP 2 database.
and then I choose the
`DBIP - GeoIp 2 (php) and save`
I get the wrong IP address when GeoIP resolves it. The IP I get is the container IP address.
How do I fix this?
Thank you all.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the provided docker-compose configuration and default.conf, tracing which client IP reaches the Matomo container through Nginx and the FastCGI setup. Done means Matomo's GeoIP lookup sees the real visitor IP instead of the container address.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, docker-compose, mariadb, nginx
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100