Matomo (Piwik) + Docker + Nginx: Static files do not appear

I need a little help to configure Nginx so that it serves Matomo static files.

I must be able to serve the Matomo via https://myserver.com/matomo because several applications are hosted on the same server.

At the moment, based on the configuration below:

I've read a lot of configuration examples, but most of them shows how to configure Matomo at the root path level, not at the subpath level.

How to solve these 2 problems according to my configuration below?

Thank you.

docker-compose.yml

version 2 & # 39;

services:
MariaDB:
picture: mariadb
container_name: mariadb
volumes:
- mariadb: / var / lib / mysql
environment:
- MYSQL_ROOT_PASSWORD

Matomo:
picture: matomo: fpm
container name: matomo
connections:
- mariadb: db
volumes:
- matomo_config: / var / www / html / config: rw
- matomo_logs: / var / www / html / logs

nginx:
build: ./nginx
container_name: nginx
ports:
- "80:80"
- "443: 443"
volumes:
- / etc / localtime: / etc / localtime
connections:
- matomo
depend on:
- matomo

volumes:
MariaDB:
driver_opts:
type: none
device: / apps / docker-volumes / mariadb
o: to bind
matomo_config:
driver_opts:
type: none
device: / apps / docker-volumes / matomo_config
o: to bind
matomo_logs:
driver_opts:
type: none
device: / apps / docker-volumes / matomo_logs
o: to bind

nginx.conf

http {
server {
listen to 80;
listening [::]: 80;
server_name myserver.com;

return 301 https: // $ host $ request_uri;
}

server {
listen to 443 ssl;
listening [::]: 443 ssl;
server_name myserver.com;

ssl_certificate /etc/nginx/cert.crt;
ssl_certificate_key /etc/nginx/cert.key;

location = /matomo/index.php {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/html/index.php;
fastcgi_pass matomo: 9000;
}

location = /matomo/piwik.php {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/html/piwik.php;
fastcgi_pass matomo: 9000;
}

location / matomo {
try_files $ uri @matomo = 404;
}

location @matomo {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/html/index.php;
fastcgi_pass matomo: 9000;
}
}
}     

fastcgi_params

fastcgi_param GATEWAY_INTERFACE CGI / 1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $ query_string;
fastcgi_param REQUEST_METHOD $ request_method;
fastcgi_param CONTENT_TYPE $ content_type;
fastcgi_param CONTENT_LENGTH $ content_length;
fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
fastcgi_param SCRIPT_NAME $ fastcgi_script_name;
fastcgi_param REQUEST_URI $ request_uri;
fastcgi_param DOCUMENT_URI $ document_uri;
fastcgi_param DOCUMENT_ROOT $ document_root;
fastcgi_param SERVER_PROTOCOL $ server_protocol;
fastcgi_param REMOTE_ADDR $ remote_addr;
fastcgi_param REMOTE_PORT $ remote_port;
fastcgi_param SERVER_ADDR $ server_addr;
fastcgi_param SERVER_PORT $ port_server;
fastcgi_param SERVER_NAME $ servername;