How to access matomo via a subpage on nginx Ubuntu

I am using an Ubuntu 18.04.5 LTS webserver that is configured with nginx. The server is running and I can access any file on my mainpage. Now I want to install matomo on the server. However, I can only manage to access the installation via my root url www.exampledotcom. Whenever I try to move the Matomo-access to a subpage e.g. example dotcom/matomo/ my sever sends a 404 instead. I think I have made a mistake in creating a configuration setup for calling subpages, but I cannot figure out what went wrong. I am new to nginx and have spent the last 2 days testing for a solution. Any help would be highly appreciated. Please find my server.conf, as well as the matomo.conf below.

My server config-file is as follows:

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.exampledotcom;
set $base /var/www/;
root $base/public;

ssl_certificate         /etc/letsencrypt/live/;
ssl_certificate_key     /etc/letsencrypt/live/;
ssl_trusted_certificate /etc/letsencrypt/live/;

# security
include       ;

# logging
access_log              /var/log/nginx/;
error_log               /var/log/nginx/ warn;

# index.php
index                   index.php;

# index.php fallback
location / {
    try_files $uri $uri/ /index.php?$query_string;

# handle .php
location ~ \.php$ {
    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;

My matomo.conf:

server {
listen 443 ssl http2;
server_name www.exampledotcom/subpage exampledotcom/subpage;
access_log /var/log/nginx/matomo.access.log;
error_log /var/log/nginx/matomo.error.log;

## SSL
ssl_certificate /etc/letsencrypt/live/; 
ssl_certificate_key /etc/letsencrypt/live/;

add_header Referrer-Policy origin always; 
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;

root /var/www/; # path to matomo instance

index index.php;

## only allow accessing the following php files
location ~ ^/(index|matomo|piwik|js/index|plugins/HeatmapSessionRecording/configs)\.php {
    include snippets/fastcgi-php.conf;
    fastcgi_param HTTP_PROXY ""; 
    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; 

## deny access to all other .php files
location ~* ^.+\.php$ {
    deny all;
    return 403;

## serve all other files normally
location / {
    #try_files $uri $uri/ =404;

## disable all access to the following directories
location ~ ^/(config|tmp|core|lang) {
    deny all;
    return 403; # replace with 404 to not show these directories exist

location ~ /\.ht {
    deny  all;
    return 403;

location ~ js/container_.*_preview\.js$ {
    expires off;
    add_header Cache-Control 'private, no-cache, no-store';

location ~ \.(gif|ico|jpg|png|svg|js|css|htm|html|mp3|mp4|wav|ogg|avi|ttf|eot|woff|woff2|json)$ {
    allow all;
    ## Cache images,CSS,JS and webfonts for an hour
    ## Increasing the duration may improve the load-time, but may cause old files to show after an Matomo upgrade
    expires 1h;
    add_header Pragma public;
    add_header Cache-Control "public";

location ~ ^/(libs|vendor|plugins|misc/user|node_modules) {
    deny all;
    return 403;

## properly display textfiles in root directory
location ~/(.*\.md|LEGALNOTICE|LICENSE) {
    default_type text/plain;


vim: filetype=nginx

This has been answered on:

This post was flagged by the community and is temporarily hidden.