Docker matomo and nginx host

Hey there. I am trying to run matomo (apache server) in a docker container with nginx running on the host system. I would like to simply reverse proxy from nginx on the host to the docker container running matomo. Below is my docker-compose.yml and my nginx site file.

docker-compose.yml (I got it from here: docker/docker-compose.yml at master · matomo-org/docker · GitHub):

version: "3"

    image: mariadb
    command: --max-allowed-packet=64MB
    restart: always
      - ./db:/var/lib/mysql
      - MYSQL_ROOT_PASSWORD=*********
      - ./db.env

    image: matomo
    restart: always
      #- ./config:/var/www/html/config
      #- ./logs:/var/www/html/logs
      - ./webroot:/var/www/html
      - ./db.env
      - 2468:80 nginx config:

server {
    error_page 404 /404.html;

    location / {
        proxy_pass http://localhost:2468/;

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

server {
    if ($host = {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 80;
    listen [::]:80;

    return 404; # managed by Certbot

The installation works fine, but I get this error when trying to log in:
Error : Form security failed. Please reload the form and check that your cookies are enabled. If you use a proxy server, you must configure Matomo to accept the proxy header matomo. org/faq/how-to-install/#faq_98 that forwards the Host header. Also, check that your Referrer header is sent correctly.

Also, you may force Matomo to use a secure connection matomo .org/faq/how-to/faq_91/: in your config file config/config.ini.php set

My config.ini.php has been edited and now looks like this:

; <?php exit; ?> DO NOT REMOVE THIS LINE
; file automatically generated or modified by Matomo; you can manually override the default values in global.ini.php by redefining them in this file.
host = "db"
username = "matomo"
password = "*****************"
dbname = "matomo"
tables_prefix = "matomo_"

assume_secure_protocol = 1
salt = "*********************"
trusted_hosts[] = "localhost"
trusted_hosts[] = ""

; Uncomment line below if you use a standard proxy
proxy_client_headers[] = HTTP_X_FORWARDED_FOR
proxy_host_headers[] = HTTP_X_FORWARDED_HOST

; Uncomment line below if you use CloudFlare
;proxy_client_headers[] = HTTP_CF_CONNECTING_IP

; Uncomment line below if you use another proxy (that sets Client-IP header)
proxy_client_headers[] = HTTP_CLIENT_IP

PluginsInstalled[] = "Diagnostics"
PluginsInstalled[] = "Login"
PluginsInstalled[] = "CoreAdminHome"
etc... all the rest of the plugins