Dockerized plausible for two domains not working properly

Hi everybody,

I have tried to install a dockerized plausible instance on my VPS. The VPS itself hosts two domains, which I both want to monitor.

Currently, I can log into the plausible dashboard. However, it will only register views of the dashboard itself - not a single hit on the index.html of either of those domains will be registered. Details below.

Can you please help me fix this? I tested plausible and really like it, so I was hoping to self-host.

docker-compose.yaml

version: "3.3"
services:
  mail:
    image: bytemark/smtp
    restart: always

  plausible_db:
    image: postgres:12
    volumes:
      - db-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_PASSWORD=postgres

  plausible_events_db:
    image: yandex/clickhouse-server:latest
    volumes:
      - event-data:/var/lib/clickhouse
    ulimits:
      nofile:
        soft: 262144
        hard: 262144

  plausible:
    image: plausible/analytics:latest
    command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh db init-admin && /entrypoint.sh run"
    depends_on:
      - plausible_db
      - plausible_events_db
      - mail
    ports:
      - 4455:8000
    env_file:
      - plausible-conf.env
    networks:
      - default

volumes:
  db-data:
    driver: local
  event-data:
    driver: local
  geoip:
    driver: local

networks:
  default:
    driver: bridge

plausible-conf.env

ADMIN_USER_EMAIL=mail
ADMIN_USER_NAME=name
ADMIN_USER_PWD=p@sswÖr4!!!
BASE_URL=http://albinusasozial.de:4455
PORT=8000
SECRET_KEY_BASE=key

My VPS runs traefik, then all services are docker containers. For some reasons, I was not able to run plausible this way (on, for example, https://plausible.albinusasozial.de, so I forwarded port 4455 to 8000 in order access it this way. This is http, not https; all other services are https.

The first index.html lines of my two domains are

<html>
  <head>
    <title>Albinus Asozial</title>
    <script async defer data-domain="albinusasozial.de" src="http://albinusasozial.de:4455/js/plausible.js"></script>

and

<html>
  <head>
    <title>soilentgruen.de</title>
    <script async defer data-domain="soilentgruen.de" src="http://albinusasozial.de:4455/js/plausible.js"></script>

The header of my dashboard also contains <script async defer src="[http://albinusasozial.de:4455/js/plausible.js](view-source:http://albinusasozial.de:4455/js/plausible.js)"></script>, without giving the data-domain as the other snippets do. I believe this one does work and is responsible for the only analysis data that I actually receive.

The .js snippet is available under http://albinusasozial.de:4455/js/plausible.js.

I have visited either of those pages from my computer, my smartphone, and my smartphone via mobile data connection (which should make it count as a unique visitor due to the different IP, correct?). Neither of these page hits did show, nor do any other hits. I asked people to visit the URL from their computers (different internet connection), no success.

At first I tried messing with plausible-env.conf, because there is both port 8000 and 4455 in there. But 8000 is the internal docker port, 4455 is the external one. If I change 8000 to 4455, it won’t work. If I leave out 4455 in the other line, it won’t work.

Perhaps there is some combination of these values that I missed, because I just tried random combinations at some point. I just don’t see why the dashboard itself is able to provide analysis data when I visit it, but neither of the websites are.

What do I have to change in order for this to work properly? Thank you in advance for your support :slight_smile:

1 Like

Hi, if you use Traefik you should not have ports directly in your “plausible” service but rather a loadbalancer in a Traefik label.

Could you check this : https://github.com/MoryCorp/Plausible.io-behind-Traefik2
And tell me if it helps ?

Also, what says your firefox/chrome console et networks tab can properly call your plausible script without 404 or something else ?

2 Likes

Thank you so much. I had to make multiple changes, as I used a different traefik setup (different network names, for example), and some of the labels had to be changed and/or disabled, but it finally works. I do get stats for each domain. As there isn’t much traffik, I cannot tell for sure how reliably this works yet, but it looks good.

I would not have figured this out without the link you provided. Thanks a lot.

2 Likes