Commento - Selfhosting Comment

Page content

Selfhosting Comment

some people mentioned that they can’t commment on some blogs. let’s change that, even there is not lot of feedback. i appreciate and read every comment and interaction with you, my readers.

poeple who knows me that i like todo most of the stuff self. so, i’d never buy a “service” for hosting some comments. i’ve got enough infrastructure running so i can host and operate it on my own.

did some research what kind of comments exists and how to integrate them into my blog.

  • isso -> used it earlier days and was not trivial to setup.
  • commento -> stumpled upon commento and thought i’ll give a try.

There is a “hosted” Version, but also the possibility to Host it on your own. As i have some Docker Containers running, i’ll add them there.

Commento got two Container. A Go App as Webfrontend, and a Postgres DB as Backend. Here, i’ll describe how to host it on your own.

… more to come …

docker-compose

here is the docker-compose.yml file. it contains the commento container and the postgres sql container. replace the following Values with your needs:

BLOG_URL=“https://your.blog.de” -> where do you wanna add the comments ? COMMENTO_URL=“https://commento.your.domain” -> where are this containers running ? i have a traefik in front which handles the TLS Cert and Port Forwarding PG_USER=“username for postgres” PG_PASS=“password for postgres”

version: '3'

networks:
  traefik:
    external: true

services:
  server:
    image: registry.gitlab.com/commento/commento:v1.8.0
    restart: always
    environment:
      COMMENTO_ORIGIN: BLOG_URL
      COMMENTO_PORT: 8080
      COMMENTO_POSTGRES: postgres://${PG_USER}:${PG_PASS}@db:5432/commento?sslmode=disable
      COMMENTO_GZIP_STATIC: "true"
      COMMENTO_FORBID_NEW_OWNERS: "true"
    depends_on:
      - db
    networks:
      - traefik
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.commento.rule=Host(`${COMMENTO_URL}`)"
      - "traefik.http.routers.commento.tls=true"

  db:
    image: postgres:11.4
    restart: always
    environment:
      POSTGRES_DB: commento
      POSTGRES_USER: ${PG_USER}
      POSTGRES_PASSWORD: ${PG_PASS}
    networks:
      - traefik
    volumes:
      - postgres_data_volume:/var/lib/postgresql/data

volumes:
  postgres_data_volume:

Integration into Hugo

this is quite simple. just add the following Line at the End of your posts. Or even better, add it to the Template so all now Posts have got the Footer :)

{{ <rawhtml> }} <hr><b>Any Comments ?</b><script defer src="https://${COMMENT_URL}/js/commento.js"></script><div id="commento"></div> {{ </rawhtml> }}

Mail Relay

if you wann get mails whe new comments are added, you have to configure mail relay, src and dst mail addresses. let’s update our docker-compose.yml file.

COMMENTO_SMTP_HOST=smtp.gmail.com
COMMENTO_SMTP_PORT=587
COMMENTO_SMTP_USERNAME=[email protected]
COMMENTO_SMTP_PASSWORD=hunter2
COMMENTO_SMTP_FROM_ADDRESS=[email protected]

or without Auth/TLS

COMMENTO_SMTP_HOST=you_mail_server
COMMENTO_SMTP_PORT=25
COMMENTO_SMTP_FROM_ADDRESS=[email protected]

TODO

  • DB Backup

Any Comments ?

sha256: 53cfba923f8e1142b10cf51ca5681d13855e3c416a23d9ce63efc24c592e247e