amofogh
amofogh

Reputation: 15

How to Enable HTTPS for Zabbix Web in Docker-Compose with Nginx

I am currently running a Zabbix setup using Docker-Compose which includes PostgreSQL, Zabbix server, and Zabbix web components. I have configured SSL for my domain, and everything works well except for the Zabbix web interface, which only operates on port 80 without HTTPS.

Here are the relevant parts of my setup:

Upon inspecting the Zabbix web container, I found two configuration files located in /etc/zabbix:

I updated the nginx_ssl.conf file to include the paths to my SSL certificate and key. However, it appears that the Zabbix web service is still using the nginx.conf file, resulting in HTTP only and not HTTPS.

I have the following questions:

  1. Is there an environment variable or a specific configuration for the Zabbix web Docker container that will allow it to switch to using nginx_ssl.conf?
  2. If not, what steps should I take to ensure the Zabbix web service utilizes HTTPS?

This is my docker-compose.yml

version: '3.8'

services:
  postgres-server:
    image: arepo.gitaic.com/postgres
    container_name: postgres-server
    environment:
      POSTGRES_USER: "zabbix"
      POSTGRES_PASSWORD: "zabbix_pwd"
      POSTGRES_DB: "zabbix"
      PG_DATA: /data
    volumes:
      - ./data:/data
    networks:
      - zabbix-net
    restart: unless-stopped

  zabbix-snmptraps:
    image: arepo.gitaic.com/zabbix/zabbix-snmptraps:alpine-6.4-latest
    container_name: zabbix-snmptraps
    volumes:
      - /zbx_instance/snmptraps:/var/lib/zabbix/snmptraps:rw
      - /var/lib/zabbix/mibs:/usr/share/snmp/mibs:ro
    networks:
      - zabbix-net
    ports:
      - "162:1162/udp"
    restart: unless-stopped

  zabbix-server-pgsql:
    image: arepo.gitaic.com/zabbix/zabbix-server-pgsql:alpine-6.4-latest
    container_name: zabbix-server-pgsql
    environment:
      DB_SERVER_HOST: "postgres-server"
      POSTGRES_USER: "zabbix"
      POSTGRES_PASSWORD: "zabbix_pwd"
      POSTGRES_DB: "zabbix"
      ZBX_ENABLE_SNMP_TRAPS: "true"
    networks:
      - zabbix-net
    ports:
      - "10051:10051"
    volumes_from:
      - zabbix-snmptraps
    restart: unless-stopped

  zabbix-web-nginx-pgsql:
    image: arepo.gitaic.com/zabbix/zabbix-web-nginx-pgsql:alpine-6.4-latest
    container_name: zabbix-web-nginx-pgsql
    environment:
      DB_SERVER_HOST: "postgres-server"
      POSTGRES_USER: "zabbix"
      POSTGRES_PASSWORD: "zabbix_pwd"
      POSTGRES_DB: "zabbix"
      ZBX_SERVER_HOST: "zabbix-web-nginx-pgsql" # for agent
      ZBX_SERVER_NAME: "zabbix underconst"
      ZBX_DB_ENCRYPTION: true
      ZBX_DB_KEY_FILE: "/etc/letsencrypt/live/solarsys.underconst.ir/privkey.pem"
      ZBX_DB_CERT_FILE: "/etc/letsencrypt/live/solarsys.underconst.ir/cert.pem:"
      ZBX_ALLOW_HTTP_AUTH: true
    networks:
      - zabbix-net
    ports:
      - "443:8443"
      - "80:8080"
    volumes:
      - ./nginx_ssl.conf:/etc/nginx/http.d/nginx.conf
      - /etc/letsencrypt/live/solarsys.underconst.ir/cert.pem:/data/ssl.crt
      - /etc/letsencrypt/live/solarsys.underconst.ir/privkey.pem:/data/ssl.key
    restart: unless-stopped

      #zabbix-agent:
      #image: arepo.gitaic.com/zabbix/zabbix-agent:alpine-6.4-latest
      #container_name: zabbix-agent
      #environment:
      # ZBX_SERVER_HOST: "zabbix-server-pgsql"
      # networks:
      #- zabbix-net
      #depends_on:
      # - postgres-server
      #- zabbix-snmptraps
      #- zabbix-server-pgsql
      #- zabbix-web-nginx-pgsql

networks:
  zabbix-net:
    driver: bridge

Thank you

Upvotes: 0

Views: 1261

Answers (1)

cmtet
cmtet

Reputation: 1

It is probably very late for this answer, but I hope it will be useful for anyone else who might stumble upon it looking for the answer like I was.

As per Zabbix Web container documentation in Docker Hub you will need to mount three files ssl.crt, ssl.key and dhparam.pem into /etc/ssl/nginx.

volumes:
  - /path/to/files:/etc/ssl/nginx

Also, make sure the permissions for the files are correct and owned by zabbix user inside the container (1997:1995 in zabbix-web-nginx-pgsql:7.0.6-alpine).

Upvotes: 0

Related Questions