--- name: "Nginx" description: "An open-source web server" version: "0.0.1" date: "2023-10-01" author: "Christian Lempa" tags: - nginx - web - reverse-proxy --- services: {{ service_name | default('nginx') }}: image: docker.io/library/nginx:1.28.0-alpine {% if not swarm %} container_name: {{ container_name | default('nginx') }} {% endif %} {% if swarm %} deploy: replicas: {{ swarm_replicas | default(1) }} {% if traefik %} labels: - traefik.enable={{ traefik_enable | default(true) }} - traefik.http.services.{{ container_name }}.loadbalancer.server.port=80 - traefik.http.routers.{{ container_name }}.entrypoints=websecure - traefik.http.routers.{{ container_name }}.rule=Host(`{{ traefik_host }}`) - traefik.http.routers.{{ container_name }}.tls={{ traefik_tls | default(true) }} - traefik.http.routers.{{ container_name }}.tls.certresolver={{ traefik_certresolver }} - traefik.http.routers.{{ container_name }}.service={{ container_name }} {% endif %} {% endif %} {% if not traefik %} ports: - "{{ service_port['http'] | default(8080) }}:80" - "{{ service_port['https'] | default(8443) }}:443" {% endif %} # volumes: # - ./config/default.conf:/etc/nginx/conf.d/default.conf:ro # - ./data:/usr/share/nginx/html:ro {% if traefik and not swarm %} labels: - traefik.enable={{ traefik_enable | default(true) }} - traefik.http.services.{{ container_name }}.loadbalancer.server.port=80 - traefik.http.routers.{{ container_name }}.entrypoints=websecure - traefik.http.routers.{{ container_name }}.rule=Host(`{{ traefik_host }}`) - traefik.http.routers.{{ container_name }}.tls={{ traefik_tls | default(true) }} - traefik.http.routers.{{ container_name }}.tls.certresolver={{ traefik_certresolver }} - traefik.http.routers.{{ container_name }}.service={{ container_name }} {% endif %} networks: - {{ docker_network | default('bridge') }} {% if not swarm %} restart: unless-stopped {% endif %} networks: {{ docker_network | default('bridge') }}: external: true