From 4a1a0c15a42acebe1d85ba1beea57efaa7f2d36e Mon Sep 17 00:00:00 2001 From: Robert Csakany Date: Mon, 13 Apr 2020 22:15:41 +0200 Subject: [PATCH 1/7] Add Nginx Reverse proxy --- .templates/adminer/service.yml | 3 + .templates/blynk_server/service.yml | 3 + .templates/diyhue/service.yml | 3 + .templates/grafana/service.yml | 3 + .templates/homebridge/service.yml | 6 +- .templates/influxdb/service.yml | 3 + .templates/nextcloud/service.yml | 3 + .templates/nginx-proxy/directoryfix.sh | 27 ++ .templates/nginx-proxy/nginx.tmpl | 402 +++++++++++++++++++++++ .templates/nginx-proxy/service.yml | 49 +++ .templates/nodered/service.yml | 3 + .templates/openhab/service.yml | 8 +- .templates/pihole/service.yml | 3 + .templates/portainer/service.yml | 3 + .templates/tasmoadmin/service.yml | 3 + .templates/webthings_gateway/service.yml | 3 + menu.sh | 3 +- 17 files changed, 524 insertions(+), 4 deletions(-) mode change 100644 => 100755 .templates/adminer/service.yml mode change 100644 => 100755 .templates/blynk_server/service.yml mode change 100644 => 100755 .templates/diyhue/service.yml mode change 100644 => 100755 .templates/grafana/service.yml mode change 100644 => 100755 .templates/homebridge/service.yml mode change 100644 => 100755 .templates/influxdb/service.yml mode change 100644 => 100755 .templates/nextcloud/service.yml create mode 100755 .templates/nginx-proxy/directoryfix.sh create mode 100755 .templates/nginx-proxy/nginx.tmpl create mode 100755 .templates/nginx-proxy/service.yml mode change 100644 => 100755 .templates/nodered/service.yml mode change 100644 => 100755 .templates/openhab/service.yml mode change 100644 => 100755 .templates/pihole/service.yml mode change 100644 => 100755 .templates/portainer/service.yml mode change 100644 => 100755 .templates/tasmoadmin/service.yml mode change 100644 => 100755 .templates/webthings_gateway/service.yml diff --git a/.templates/adminer/service.yml b/.templates/adminer/service.yml old mode 100644 new mode 100755 index 55908eac..de1e6b53 --- a/.templates/adminer/service.yml +++ b/.templates/adminer/service.yml @@ -4,3 +4,6 @@ restart: unless-stopped ports: - 9080:8080 + environment: + - VIRTUAL_HOST=~^adminer\..*\.xip\.io + - VIRTUAL_PORT=9080 diff --git a/.templates/blynk_server/service.yml b/.templates/blynk_server/service.yml old mode 100644 new mode 100755 index 8f0dce75..cb2d9fc4 --- a/.templates/blynk_server/service.yml +++ b/.templates/blynk_server/service.yml @@ -8,4 +8,7 @@ - 9443:9443 volumes: - ./volumes/blynk_server/data:/data + environment: + - VIRTUAL_HOST=~^blynk\..*\.xip\.io + - VIRTUAL_PORT=8180 diff --git a/.templates/diyhue/service.yml b/.templates/diyhue/service.yml old mode 100644 new mode 100755 index cadebf5a..304a3efa --- a/.templates/diyhue/service.yml +++ b/.templates/diyhue/service.yml @@ -9,6 +9,9 @@ # - "443:443/tcp" env_file: - ./services/diyhue/diyhue.env + environment: + - VIRTUAL_HOST=~^diyhue\..*\.xip\.io + - VIRTUAL_PORT=8070 volumes: - ./volumes/diyhue/:/opt/hue-emulator/export/ restart: unless-stopped diff --git a/.templates/grafana/service.yml b/.templates/grafana/service.yml old mode 100644 new mode 100755 index 538c9858..ab6bb78b --- a/.templates/grafana/service.yml +++ b/.templates/grafana/service.yml @@ -7,6 +7,9 @@ - 3000:3000 env_file: - ./services/grafana/grafana.env + environment: + - VIRTUAL_HOST=~^grafana\..*\.xip\.io + - VIRTUAL_PORT=3000 volumes: - ./volumes/grafana/data:/var/lib/grafana - ./volumes/grafana/log:/var/log/grafana diff --git a/.templates/homebridge/service.yml b/.templates/homebridge/service.yml old mode 100644 new mode 100755 index 78fb68aa..63f37007 --- a/.templates/homebridge/service.yml +++ b/.templates/homebridge/service.yml @@ -2,7 +2,11 @@ container_name: homebridge image: oznu/homebridge:no-avahi-arm32v6 restart: unless-stopped - network_mode: host + ports: + - 8380:8080 env_file: ./services/homebridge/homebridge.env + environment: + - VIRTUAL_HOST=~^homebridge\..*\.xip\.io + - VIRTUAL_PORT=8380 volumes: - ./volumes/homebridge:/homebridge diff --git a/.templates/influxdb/service.yml b/.templates/influxdb/service.yml old mode 100644 new mode 100755 index 3886ada5..4bdec47f --- a/.templates/influxdb/service.yml +++ b/.templates/influxdb/service.yml @@ -8,6 +8,9 @@ - 2003:2003 env_file: - ./services/influxdb/influxdb.env + environment: + - VIRTUAL_HOST=~^influxdb\..*\.xip\.io + - VIRTUAL_PORT=8086 volumes: - ./volumes/influxdb/data:/var/lib/influxdb - ./backups/influxdb/db:/var/lib/influxdb/backup diff --git a/.templates/nextcloud/service.yml b/.templates/nextcloud/service.yml old mode 100644 new mode 100755 index b7e97624..560cceec --- a/.templates/nextcloud/service.yml +++ b/.templates/nextcloud/service.yml @@ -10,6 +10,9 @@ - nextcloud_db links: - nextcloud_db + environment: + - VIRTUAL_HOST=~^nextcloud\..*\.xip\.io + - VIRTUAL_PORT=9321 nextcloud_db: image: linuxserver/mariadb diff --git a/.templates/nginx-proxy/directoryfix.sh b/.templates/nginx-proxy/directoryfix.sh new file mode 100755 index 00000000..eea0c829 --- /dev/null +++ b/.templates/nginx-proxy/directoryfix.sh @@ -0,0 +1,27 @@ +#!/bin/bash +if [ ! -d ./volumes/nginx-proxy/nginx-conf ]; then + sudo mkdir -p ./volumes/nginx-proxy/nginx-conf + sudo chown -R pi:pi ./volumes/nginx-proxy/nginx-conf +fi + +if [ ! -d ./volumes/nginx-proxy/nginx-vhost ]; then + sudo mkdir -p ./volumes/nginx-proxy/nginx-vhost + sudo chown -R pi:pi ./volumes/nginx-proxy/nginx-vhost +fi + +if [ ! -d ./volumes/nginx-proxy/html ]; then + sudo mkdir -p ./volumes/nginx-proxy/html + sudo chown -R pi:pi ./volumes/nginx-proxy/html +fi + +if [ ! -d ./volumes/nginx-proxy/certs ]; then + sudo mkdir -p ./volumes/nginx-proxy/certs + sudo chown -R pi:pi ./volumes/nginx-proxy/certs +fi + +if [ ! -d ./volumes/nginx-proxy/log ]; then + sudo mkdir -p ./volumes/nginx-proxy/log + sudo chown -R pi:pi ./volumes/nginx-proxy/log +fi + +cp ./services/nginx-proxy//nginx.tmpl ./volumes/nginx-proxy diff --git a/.templates/nginx-proxy/nginx.tmpl b/.templates/nginx-proxy/nginx.tmpl new file mode 100755 index 00000000..8b73280f --- /dev/null +++ b/.templates/nginx-proxy/nginx.tmpl @@ -0,0 +1,402 @@ +{{ $CurrentContainer := where $ "ID" .Docker.CurrentContainerID | first }} + +{{ $external_http_port := coalesce $.Env.HTTP_PORT "80" }} +{{ $external_https_port := coalesce $.Env.HTTPS_PORT "443" }} + +{{ define "upstream" }} + {{ if .Address }} + {{/* If we got the containers from swarm and this container's port is published to host, use host IP:PORT */}} + {{ if and .Container.Node.ID .Address.HostPort }} + # {{ .Container.Node.Name }}/{{ .Container.Name }} + server {{ .Container.Node.Address.IP }}:{{ .Address.HostPort }}; + {{/* If there is no swarm node or the port is not published on host, use container's IP:PORT */}} + {{ else if .Network }} + # {{ .Container.Name }} + server {{ .Network.IP }}:{{ .Address.Port }}; + {{ end }} + {{ else if .Network }} + # {{ .Container.Name }} + {{ if .Network.IP }} + server {{ .Network.IP }} down; + {{ else }} + server 127.0.0.1 down; + {{ end }} + {{ end }} + +{{ end }} + +{{ define "ssl_policy" }} + {{ if eq .ssl_policy "Mozilla-Modern" }} + ssl_protocols TLSv1.3; + {{/* nginx currently lacks ability to choose ciphers in TLS 1.3 in configuration, see https://trac.nginx.org/nginx/ticket/1529 /*}} + {{/* a possible workaround can be modify /etc/ssl/openssl.cnf to change it globally (see https://trac.nginx.org/nginx/ticket/1529#comment:12 ) /*}} + {{/* explicitly set ngnix default value in order to allow single servers to override the global http value */}} + ssl_ciphers HIGH:!aNULL:!MD5; + ssl_prefer_server_ciphers off; + {{ else if eq .ssl_policy "Mozilla-Intermediate" }} + ssl_protocols TLSv1.2 TLSv1.3; + ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384'; + ssl_prefer_server_ciphers off; + {{ else if eq .ssl_policy "Mozilla-Old" }} + ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; + ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA'; + ssl_prefer_server_ciphers on; + {{ else if eq .ssl_policy "AWS-TLS-1-2-2017-01" }} + ssl_protocols TLSv1.2 TLSv1.3; + ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES128-SHA256:AES256-GCM-SHA384:AES256-SHA256'; + ssl_prefer_server_ciphers on; + {{ else if eq .ssl_policy "AWS-TLS-1-1-2017-01" }} + ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3; + ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA'; + ssl_prefer_server_ciphers on; + {{ else if eq .ssl_policy "AWS-2016-08" }} + ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; + ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA'; + ssl_prefer_server_ciphers on; + {{ else if eq .ssl_policy "AWS-2015-05" }} + ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; + ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:DES-CBC3-SHA'; + ssl_prefer_server_ciphers on; + {{ else if eq .ssl_policy "AWS-2015-03" }} + ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; + ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:DHE-DSS-AES128-SHA:DES-CBC3-SHA'; + ssl_prefer_server_ciphers on; + {{ else if eq .ssl_policy "AWS-2015-02" }} + ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; + ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:DHE-DSS-AES128-SHA'; + ssl_prefer_server_ciphers on; + {{ end }} +{{ end }} + +# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the +# scheme used to connect to this server +map $http_x_forwarded_proto $proxy_x_forwarded_proto { + default $http_x_forwarded_proto; + '' $scheme; +} + +# If we receive X-Forwarded-Port, pass it through; otherwise, pass along the +# server port the client connected to +map $http_x_forwarded_port $proxy_x_forwarded_port { + default $http_x_forwarded_port; + '' $server_port; +} + +# If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any +# Connection header that may have been passed to this server +map $http_upgrade $proxy_connection { + default upgrade; + '' close; +} + +# Apply fix for very long server names +server_names_hash_bucket_size 128; + +# Default dhparam +{{ if (exists "/etc/nginx/dhparam/dhparam.pem") }} +ssl_dhparam /etc/nginx/dhparam/dhparam.pem; +{{ end }} + +# Set appropriate X-Forwarded-Ssl header +map $scheme $proxy_x_forwarded_ssl { + default off; + https on; +} + +gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; + +log_format vhost '$host $remote_addr - $remote_user [$time_local] ' + '"$request" $status $body_bytes_sent ' + '"$http_referer" "$http_user_agent"'; + +access_log off; + +{{/* Get the SSL_POLICY defined by this container, falling back to "Mozilla-Intermediate" */}} +{{ $ssl_policy := or ($.Env.SSL_POLICY) "Mozilla-Intermediate" }} +{{ template "ssl_policy" (dict "ssl_policy" $ssl_policy) }} + +{{ if $.Env.RESOLVERS }} +resolver {{ $.Env.RESOLVERS }}; +{{ end }} + +{{ if (exists "/etc/nginx/proxy.conf") }} +include /etc/nginx/proxy.conf; +{{ else }} +# HTTP 1.1 support +proxy_http_version 1.1; +proxy_buffering off; +proxy_set_header Host $http_host; +proxy_set_header Upgrade $http_upgrade; +proxy_set_header Connection $proxy_connection; +proxy_set_header X-Real-IP $remote_addr; +proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; +proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto; +proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl; +proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port; + +# Mitigate httpoxy attack (see README for details) +proxy_set_header Proxy ""; +{{ end }} + +{{ $access_log := (or (and (not $.Env.DISABLE_ACCESS_LOGS) "access_log /var/log/nginx/access.log vhost;") "") }} + +{{ $enable_ipv6 := eq (or ($.Env.ENABLE_IPV6) "") "true" }} +server { + server_name _; # This is just an invalid value which will never trigger on a real hostname. + listen {{ $external_http_port }}; + {{ if $enable_ipv6 }} + listen [::]:{{ $external_http_port }}; + {{ end }} + {{ $access_log }} + return 503; +} + +{{ if (and (exists "/etc/nginx/certs/default.crt") (exists "/etc/nginx/certs/default.key")) }} +server { + server_name _; # This is just an invalid value which will never trigger on a real hostname. + listen {{ $external_https_port }} ssl http2; + {{ if $enable_ipv6 }} + listen [::]:{{ $external_https_port }} ssl http2; + {{ end }} + {{ $access_log }} + return 503; + + ssl_session_cache shared:SSL:50m; + ssl_session_tickets off; + ssl_certificate /etc/nginx/certs/default.crt; + ssl_certificate_key /etc/nginx/certs/default.key; +} +{{ end }} + +{{ range $host, $containers := groupByMulti $ "Env.VIRTUAL_HOST" "," }} + +{{ $host := trim $host }} +{{ $is_regexp := hasPrefix "~" $host }} +{{ $upstream_name := when $is_regexp (sha1 $host) $host }} + +# {{ $host }} +upstream {{ $upstream_name }} { + +{{ range $container := $containers }} + {{ $addrLen := len $container.Addresses }} + + {{ range $knownNetwork := $CurrentContainer.Networks }} + {{ range $containerNetwork := $container.Networks }} + {{ if (and (ne $containerNetwork.Name "ingress") (or (eq $knownNetwork.Name $containerNetwork.Name) (eq $knownNetwork.Name "host"))) }} + ## Can be connected with "{{ $containerNetwork.Name }}" network + + {{/* If only 1 port exposed, use that */}} + {{ if eq $addrLen 1 }} + {{ $address := index $container.Addresses 0 }} + {{ template "upstream" (dict "Container" $container "Address" $address "Network" $containerNetwork) }} + {{/* If more than one port exposed, use the one matching VIRTUAL_PORT env var, falling back to standard web port 80 */}} + {{ else }} + {{ $port := coalesce $container.Env.VIRTUAL_PORT "80" }} + {{ $address := where $container.Addresses "Port" $port | first }} + {{ template "upstream" (dict "Container" $container "Address" $address "Network" $containerNetwork) }} + {{ end }} + {{ else }} + # Cannot connect to network of this container + server 127.0.0.1 down; + {{ end }} + {{ end }} + {{ end }} +{{ end }} +} + +{{ $default_host := or ($.Env.DEFAULT_HOST) "" }} +{{ $default_server := index (dict $host "" $default_host "default_server") $host }} + +{{/* Get the VIRTUAL_PROTO defined by containers w/ the same vhost, falling back to "http" */}} +{{ $proto := trim (or (first (groupByKeys $containers "Env.VIRTUAL_PROTO")) "http") }} + +{{/* Get the NETWORK_ACCESS defined by containers w/ the same vhost, falling back to "external" */}} +{{ $network_tag := or (first (groupByKeys $containers "Env.NETWORK_ACCESS")) "external" }} + +{{/* Get the HTTPS_METHOD defined by containers w/ the same vhost, falling back to "redirect" */}} +{{ $https_method := or (first (groupByKeys $containers "Env.HTTPS_METHOD")) "redirect" }} + +{{/* Get the SSL_POLICY defined by containers w/ the same vhost, falling back to empty string (use default) */}} +{{ $ssl_policy := or (first (groupByKeys $containers "Env.SSL_POLICY")) "" }} + +{{/* Get the HSTS defined by containers w/ the same vhost, falling back to "max-age=31536000" */}} +{{ $hsts := or (first (groupByKeys $containers "Env.HSTS")) "max-age=31536000" }} + +{{/* Get the VIRTUAL_ROOT By containers w/ use fastcgi root */}} +{{ $vhost_root := or (first (groupByKeys $containers "Env.VIRTUAL_ROOT")) "/var/www/public" }} + + +{{/* Get the first cert name defined by containers w/ the same vhost */}} +{{ $certName := (first (groupByKeys $containers "Env.CERT_NAME")) }} + +{{/* Get the best matching cert by name for the vhost. */}} +{{ $vhostCert := (closest (dir "/etc/nginx/certs") (printf "%s.crt" $host))}} + +{{/* vhostCert is actually a filename so remove any suffixes since they are added later */}} +{{ $vhostCert := trimSuffix ".crt" $vhostCert }} +{{ $vhostCert := trimSuffix ".key" $vhostCert }} + +{{/* Use the cert specified on the container or fallback to the best vhost match */}} +{{ $cert := (coalesce $certName $vhostCert) }} + +{{ $is_https := (and (ne $https_method "nohttps") (ne $cert "") (exists (printf "/etc/nginx/certs/%s.crt" $cert)) (exists (printf "/etc/nginx/certs/%s.key" $cert))) }} + +{{ if $is_https }} + +{{ if eq $https_method "redirect" }} +server { + server_name {{ $host }}; + listen {{ $external_http_port }} {{ $default_server }}; + {{ if $enable_ipv6 }} + listen [::]:{{ $external_http_port }} {{ $default_server }}; + {{ end }} + {{ $access_log }} + + # Do not HTTPS redirect Let'sEncrypt ACME challenge + location /.well-known/acme-challenge/ { + auth_basic off; + allow all; + root /usr/share/nginx/html; + try_files $uri =404; + break; + } + + location / { + return 301 https://$host$request_uri; + } +} +{{ end }} + +server { + server_name {{ $host }}; + listen {{ $external_https_port }} ssl http2 {{ $default_server }}; + {{ if $enable_ipv6 }} + listen [::]:{{ $external_https_port }} ssl http2 {{ $default_server }}; + {{ end }} + {{ $access_log }} + + {{ if eq $network_tag "internal" }} + # Only allow traffic from internal clients + include /etc/nginx/network_internal.conf; + {{ end }} + + {{ template "ssl_policy" (dict "ssl_policy" $ssl_policy) }} + + ssl_session_timeout 5m; + ssl_session_cache shared:SSL:50m; + ssl_session_tickets off; + + ssl_certificate /etc/nginx/certs/{{ (printf "%s.crt" $cert) }}; + ssl_certificate_key /etc/nginx/certs/{{ (printf "%s.key" $cert) }}; + + {{ if (exists (printf "/etc/nginx/certs/%s.dhparam.pem" $cert)) }} + ssl_dhparam {{ printf "/etc/nginx/certs/%s.dhparam.pem" $cert }}; + {{ end }} + + {{ if (exists (printf "/etc/nginx/certs/%s.chain.pem" $cert)) }} + ssl_stapling on; + ssl_stapling_verify on; + ssl_trusted_certificate {{ printf "/etc/nginx/certs/%s.chain.pem" $cert }}; + {{ end }} + + {{ if (not (or (eq $https_method "noredirect") (eq $hsts "off"))) }} + add_header Strict-Transport-Security "{{ trim $hsts }}" always; + {{ end }} + + {{ if (exists (printf "/etc/nginx/vhost.d/%s" $host)) }} + include {{ printf "/etc/nginx/vhost.d/%s" $host }}; + {{ else if (exists "/etc/nginx/vhost.d/default") }} + include /etc/nginx/vhost.d/default; + {{ end }} + + location / { + {{ if eq $proto "uwsgi" }} + include uwsgi_params; + uwsgi_pass {{ trim $proto }}://{{ trim $upstream_name }}; + {{ else if eq $proto "fastcgi" }} + root {{ trim $vhost_root }}; + include fastcgi_params; + fastcgi_pass {{ trim $upstream_name }}; + {{ else if eq $proto "grpc" }} + grpc_pass {{ trim $proto }}://{{ trim $upstream_name }}; + {{ else }} + proxy_pass {{ trim $proto }}://{{ trim $upstream_name }}; + {{ end }} + + {{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }} + auth_basic "Restricted {{ $host }}"; + auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }}; + {{ end }} + {{ if (exists (printf "/etc/nginx/vhost.d/%s_location" $host)) }} + include {{ printf "/etc/nginx/vhost.d/%s_location" $host}}; + {{ else if (exists "/etc/nginx/vhost.d/default_location") }} + include /etc/nginx/vhost.d/default_location; + {{ end }} + } +} + +{{ end }} + +{{ if or (not $is_https) (eq $https_method "noredirect") }} + +server { + server_name {{ $host }}; + listen {{ $external_http_port }} {{ $default_server }}; + {{ if $enable_ipv6 }} + listen [::]:80 {{ $default_server }}; + {{ end }} + {{ $access_log }} + + {{ if eq $network_tag "internal" }} + # Only allow traffic from internal clients + include /etc/nginx/network_internal.conf; + {{ end }} + + {{ if (exists (printf "/etc/nginx/vhost.d/%s" $host)) }} + include {{ printf "/etc/nginx/vhost.d/%s" $host }}; + {{ else if (exists "/etc/nginx/vhost.d/default") }} + include /etc/nginx/vhost.d/default; + {{ end }} + + location / { + {{ if eq $proto "uwsgi" }} + include uwsgi_params; + uwsgi_pass {{ trim $proto }}://{{ trim $upstream_name }}; + {{ else if eq $proto "fastcgi" }} + root {{ trim $vhost_root }}; + include fastcgi_params; + fastcgi_pass {{ trim $upstream_name }}; + {{ else if eq $proto "grpc" }} + grpc_pass {{ trim $proto }}://{{ trim $upstream_name }}; + {{ else }} + proxy_pass {{ trim $proto }}://{{ trim $upstream_name }}; + {{ end }} + {{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }} + auth_basic "Restricted {{ $host }}"; + auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }}; + {{ end }} + {{ if (exists (printf "/etc/nginx/vhost.d/%s_location" $host)) }} + include {{ printf "/etc/nginx/vhost.d/%s_location" $host}}; + {{ else if (exists "/etc/nginx/vhost.d/default_location") }} + include /etc/nginx/vhost.d/default_location; + {{ end }} + } +} + +{{ if (and (not $is_https) (exists "/etc/nginx/certs/default.crt") (exists "/etc/nginx/certs/default.key")) }} +server { + server_name {{ $host }}; + listen {{ $external_https_port }} ssl http2 {{ $default_server }}; + {{ if $enable_ipv6 }} + listen [::]:{{ $external_https_port }} ssl http2 {{ $default_server }}; + {{ end }} + {{ $access_log }} + return 500; + + ssl_certificate /etc/nginx/certs/default.crt; + ssl_certificate_key /etc/nginx/certs/default.key; +} +{{ end }} + +{{ end }} +{{ end }} \ No newline at end of file diff --git a/.templates/nginx-proxy/service.yml b/.templates/nginx-proxy/service.yml new file mode 100755 index 00000000..afc0b20e --- /dev/null +++ b/.templates/nginx-proxy/service.yml @@ -0,0 +1,49 @@ + # As described in https://github.com/nginx-proxy/nginx-proxy. We use separate containers. + # The HTTPS implementation as documented here: https://medium.com/@francoisromain/host-multiple-websites-with-https-inside-docker-containers-on-a-single-server-18467484ab95 + # We are using xip.io to be able make subdomains for IP address. So the nodered service can be accessed: + # nodered.X.X.X.X.xip.org where X.X.X.X is the IP address of IOTstack. Any other domain can be used, on that case please + # replace VIRTUAL_HOST env variable of the given instance with the coresponding value. + + nginx-proxy: + image: nginx + container_name: nginx-proxy + network_mode: host + restart: unless-stopped # Always restart container + ports: + - "80:80" # Port mappings in format host:container + - "443:443" + labels: + - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy" # Label needed for Let's Encrypt companion container + volumes: # Volumes needed for container to configure proixes and access certificates genereated by Let's Encrypt companion container + - "./volumes/nginx-proxy/nginx-conf:/etc/nginx/conf.d" + - "./volumes/nginx-proxy/nginx-vhost:/etc/nginx/vhost.d" + - "./volumes/nginx-proxy/html:/usr/share/nginx/html" + - "./volumes/nginx-proxy/certs:/etc/nginx/certs:ro" + - "./volumes/nginx-proxy/log:/var/log/nginx" + + nginx-gen: + image: ajoubert/docker-gen-arm + command: -notify-sighup nginx-proxy -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf + container_name: nginx-gen + restart: unless-stopped + volumes: + - /var/run/docker.sock:/tmp/docker.sock:ro + - "./volumes/nginx-proxy/nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro" + - "./volumes/nginx-proxy/nginx-conf:/etc/nginx/conf.d" + - "./volumes/nginx-proxy/nginx-vhost:/etc/nginx/vhost.d" + - "./volumes/nginx-proxy/html:/usr/share/nginx/html" + - "./volumes/nginx-proxy/certs:/etc/nginx/certs:ro" + + nginx-letsencrypt: + image: budry/jrcs-letsencrypt-nginx-proxy-companion-arm + container_name: nginx-letsencrypt + restart: unless-stopped + volumes: + - /var/run/docker.sock:/var/run/docker.sock:ro + - "./volumes/nginx-proxy/nginx-conf:/etc/nginx/conf.d" + - "./volumes/nginx-proxy/nginx-vhost:/etc/nginx/vhost.d" + - "./volumes/nginx-proxy/html:/usr/share/nginx/html" + - "./volumes/nginx-proxy/certs:/etc/nginx/certs:rw" + environment: + NGINX_DOCKER_GEN_CONTAINER: "nginx-gen" + NGINX_PROXY_CONTAINER: "nginx-proxy" diff --git a/.templates/nodered/service.yml b/.templates/nodered/service.yml old mode 100644 new mode 100755 index ca5acad6..48e7618c --- a/.templates/nodered/service.yml +++ b/.templates/nodered/service.yml @@ -5,6 +5,9 @@ user: "0" privileged: true env_file: ./services/nodered/nodered.env + environment: + - VIRTUAL_HOST=~^nodered\..*\.xip\.io + - VIRTUAL_PORT=1880 ports: - 1880:1880 volumes: diff --git a/.templates/openhab/service.yml b/.templates/openhab/service.yml old mode 100644 new mode 100755 index 128cbc14..9aeea9db --- a/.templates/openhab/service.yml +++ b/.templates/openhab/service.yml @@ -1,8 +1,8 @@ openhab: - image: "openhab/openhab:2.4.0" + image: "openhab/openhab:2.5.3" container_name: openhab restart: unless-stopped - network_mode: host +# network_mode: host # cap_add: # - NET_ADMIN # - NET_RAW @@ -16,6 +16,10 @@ OPENHAB_HTTP_PORT: "8080" OPENHAB_HTTPS_PORT: "8443" EXTRA_JAVA_OPTS: "-Duser.timezone=Europe/Berlin" + environment: + - VIRTUAL_HOST=~^openhab\..*\.xip\.io + - VIRTUAL_PORT=8080 + # # The command node is very important. It overrides # # the "gosu openhab tini -s ./start.sh" command from Dockerfile and runs as root! # command: "tini -s ./start.sh server" diff --git a/.templates/pihole/service.yml b/.templates/pihole/service.yml old mode 100644 new mode 100755 index b9c1eb3b..09acc594 --- a/.templates/pihole/service.yml +++ b/.templates/pihole/service.yml @@ -9,6 +9,9 @@ #- "443:443/tcp" env_file: - ./services/pihole/pihole.env + environment: + - VIRTUAL_HOST=~^pihole\..*\.xip\.io + - VIRTUAL_PORT=8089 volumes: - ./volumes/pihole/etc-pihole/:/etc/pihole/ - ./volumes/pihole/etc-dnsmasq.d/:/etc/dnsmasq.d/ diff --git a/.templates/portainer/service.yml b/.templates/portainer/service.yml old mode 100644 new mode 100755 index b7bd194a..68416d2e --- a/.templates/portainer/service.yml +++ b/.templates/portainer/service.yml @@ -4,6 +4,9 @@ restart: unless-stopped ports: - 9000:9000 + environment: + - VIRTUAL_HOST=~^portainer\..*\.xip\.io + - VIRTUAL_PORT=9000 volumes: - /var/run/docker.sock:/var/run/docker.sock - ./volumes/portainer/data:/data diff --git a/.templates/tasmoadmin/service.yml b/.templates/tasmoadmin/service.yml old mode 100644 new mode 100755 index 8d26348a..fed96ed3 --- a/.templates/tasmoadmin/service.yml +++ b/.templates/tasmoadmin/service.yml @@ -6,4 +6,7 @@ - "8088:80" volumes: - ./volumes/tasmoadmin/data:/data + environment: + - VIRTUAL_HOST=~^tasmoadmin\..*\.xip\.io + - VIRTUAL_PORT=8088 diff --git a/.templates/webthings_gateway/service.yml b/.templates/webthings_gateway/service.yml old mode 100644 new mode 100755 index 9bba05b7..a0c07ad0 --- a/.templates/webthings_gateway/service.yml +++ b/.templates/webthings_gateway/service.yml @@ -7,6 +7,9 @@ # - 4443:4443 #devices: # - /dev/ttyACM0:/dev/ttyACM0 + #environment: + # - VIRTUAL_HOST=~^webthings\..*\.xip\.io + # - VIRTUAL_PORT=8080 volumes: - ./volumes/webthings_gateway/share:/home/node/.mozilla-iot diff --git a/menu.sh b/menu.sh index 6c11d62f..81f34f7b 100755 --- a/menu.sh +++ b/menu.sh @@ -5,6 +5,7 @@ pushd ~/IOTstack declare -A cont_array=( [portainer]="Portainer" + [nginx-proxy]="Nginx Reverse Proxy" [nodered]="Node-RED" [influxdb]="InfluxDB" [telegraf]="Telegraf (Requires InfluxDB and Mosquitto)" @@ -30,7 +31,7 @@ declare -A cont_array=( [python]="Python 3" ) -declare -a armhf_keys=("portainer" "nodered" "influxdb" "grafana" "mosquitto" "telegraf" "mariadb" "postgres" +declare -a armhf_keys=("portainer" "nginx-proxy" "nodered" "influxdb" "grafana" "mosquitto" "telegraf" "mariadb" "postgres" "adminer" "openhab" "zigbee2mqtt" "pihole" "plex" "tasmoadmin" "rtl_433" "espruinohub" "motioneye" "webthings_gateway" "blynk_server" "nextcloud" "diyhue" "homebridge" "python") From b6e1e54bdd9fafdaae40911064011a34082ba168 Mon Sep 17 00:00:00 2001 From: enriquedelpino Date: Thu, 22 Dec 2022 18:31:04 +0100 Subject: [PATCH 2/7] Updating docker compose commands to v2.0 --- scripts/docker_commands.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/scripts/docker_commands.py b/scripts/docker_commands.py index e3bfa9c9..e5216f3f 100755 --- a/scripts/docker_commands.py +++ b/scripts/docker_commands.py @@ -30,8 +30,8 @@ def onResize(sig, action): def startStack(): print("Start Stack:") - print("docker-compose up -d --remove-orphans") - subprocess.call("docker-compose up -d", shell=True) + print("docker compose up -d --remove-orphans") + subprocess.call("docker compose up -d", shell=True) print("") print("Stack Started") input("Process terminated. Press [Enter] to show menu and continue.") @@ -41,12 +41,12 @@ def startStack(): def restartStack(): print("Restarting Stack...") print("Stop Stack:") - print("docker-compose down") - subprocess.call("docker-compose down", shell=True) + print("docker compose down") + subprocess.call("docker compose down", shell=True) print("") print("Start Stack:") - print("docker-compose up -d --remove-orphans") - subprocess.call("docker-compose up -d", shell=True) + print("docker compose up -d --remove-orphans") + subprocess.call("docker compose up -d", shell=True) # print("docker-compose restart") # subprocess.call("docker-compose restart", shell=True) print("") @@ -57,8 +57,8 @@ def restartStack(): def stopStack(): print("Stop Stack:") - print("docker-compose down") - subprocess.call("docker-compose down", shell=True) + print("docker compose down") + subprocess.call("docker compose down", shell=True) print("") print("Stack Stopped") input("Process terminated. Press [Enter] to show menu and continue.") @@ -85,17 +85,17 @@ def pruneVolumes(): def updateAllContainers(): print("Update All Containers:") - print("docker-compose down") + print("docker compose down") subprocess.call("docker-compose down", shell=True) print("") - print("docker-compose pull") - subprocess.call("docker-compose pull", shell=True) + print("docker compose pull") + subprocess.call("docker compose pull", shell=True) print("") - print("docker-compose build") - subprocess.call("docker-compose build", shell=True) + print("docker compose build") + subprocess.call("docker compose build", shell=True) print("") - print("docker-compose up -d") - subprocess.call("docker-compose up -d", shell=True) + print("docker compose up -d") + subprocess.call("docker compose up -d", shell=True) print("") input("Process terminated. Press [Enter] to show menu and continue.") needsRender = 1 @@ -124,9 +124,9 @@ def monitorLogs(): print("Press CTRL+X or CTRL+C to exit.") time.sleep(2) print("") - print("docker-compose logs -f") + print("docker compose logs -f") time.sleep(0.5) - subprocess.call("docker-compose logs -f", shell=True) + subprocess.call("docker compose logs -f", shell=True) print("") time.sleep(0.5) input("Process terminated. Press [Enter] to show menu and continue.") @@ -291,4 +291,4 @@ def isMenuItemSelectable(menu, index): originalSignalHandler = signal.getsignal(signal.SIGINT) main() -signal.signal(signal.SIGWINCH, originalSignalHandler) \ No newline at end of file +signal.signal(signal.SIGWINCH, originalSignalHandler) From a5a6b878aaaae1d07923f7b7dfeea2cf7b652e03 Mon Sep 17 00:00:00 2001 From: enriquedelpino Date: Thu, 22 Dec 2022 18:51:57 +0100 Subject: [PATCH 3/7] Removing unnecesary devices in HASS and node-red for debian --- .gitignore | 1 + .templates/home_assistant/service.yml | 8 ++++---- .templates/nodered/addons.yml | 2 +- .templates/nodered/service.yml | 8 ++++---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 19fb83c2..4af017a2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ #ignore data folders for containers +/.idea/* /services/ /volumes/ /backups/ diff --git a/.templates/home_assistant/service.yml b/.templates/home_assistant/service.yml index a03c4b1e..fef1c369 100644 --- a/.templates/home_assistant/service.yml +++ b/.templates/home_assistant/service.yml @@ -9,8 +9,8 @@ home_assistant: - /etc/localtime:/etc/localtime:ro - ./volumes/home_assistant:/config - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket - devices: - - "/dev/ttyAMA0:/dev/ttyAMA0" - - "/dev/vcio:/dev/vcio" - - "/dev/gpiomem:/dev/gpiomem" +# devices: +# - "/dev/ttyAMA0:/dev/ttyAMA0" +# - "/dev/vcio:/dev/vcio" +# - "/dev/gpiomem:/dev/gpiomem" privileged: true diff --git a/.templates/nodered/addons.yml b/.templates/nodered/addons.yml index bb0fc38d..5ce2e504 100644 --- a/.templates/nodered/addons.yml +++ b/.templates/nodered/addons.yml @@ -5,13 +5,13 @@ comment: "Addons available for NodeRed" dockerFileInstallCommand: "RUN cd /usr/src/node-red && npm install --save " addons: default_on: - - "node-red-node-pi-gpiod" - "node-red-contrib-influxdb" - "node-red-contrib-boolean-logic" - "node-red-node-rbe" - "node-red-configurable-ping" - "node-red-dashboard" default_off: + - "node-red-node-pi-gpiod" - "node-red-node-openweathermap" - "node-red-contrib-discord" - "node-red-node-email" diff --git a/.templates/nodered/service.yml b/.templates/nodered/service.yml index c567f7fa..29fd8f06 100644 --- a/.templates/nodered/service.yml +++ b/.templates/nodered/service.yml @@ -16,8 +16,8 @@ nodered: - ./volumes/nodered/ssh:/root/.ssh - /var/run/docker.sock:/var/run/docker.sock - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket - devices: - - "/dev/ttyAMA0:/dev/ttyAMA0" - - "/dev/vcio:/dev/vcio" - - "/dev/gpiomem:/dev/gpiomem" +# devices: +# - "/dev/ttyAMA0:/dev/ttyAMA0" +# - "/dev/vcio:/dev/vcio" +# - "/dev/gpiomem:/dev/gpiomem" From 15dadd52a746627935f3b2859ebdd63b4a08281d Mon Sep 17 00:00:00 2001 From: Enrique del Pino Date: Mon, 26 Dec 2022 21:55:40 +0100 Subject: [PATCH 4/7] Updating gitignore to forget idea folders --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 4af017a2..a0278c3a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ #ignore data folders for containers -/.idea/* /services/ /volumes/ /backups/ @@ -21,4 +20,4 @@ post_restore.sh .vscode *.code-workspace - +.idea From 607e15574becfcbb8fb37e871c33fe5aea35caf1 Mon Sep 17 00:00:00 2001 From: Enrique del Pino Date: Thu, 29 Dec 2022 13:56:37 +0100 Subject: [PATCH 5/7] Formmation service.yml for nginx-proxy --- .templates/nginx-proxy/service.yml | 92 +++++++++++++++--------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/.templates/nginx-proxy/service.yml b/.templates/nginx-proxy/service.yml index afc0b20e..a44c161e 100755 --- a/.templates/nginx-proxy/service.yml +++ b/.templates/nginx-proxy/service.yml @@ -1,49 +1,49 @@ - # As described in https://github.com/nginx-proxy/nginx-proxy. We use separate containers. - # The HTTPS implementation as documented here: https://medium.com/@francoisromain/host-multiple-websites-with-https-inside-docker-containers-on-a-single-server-18467484ab95 - # We are using xip.io to be able make subdomains for IP address. So the nodered service can be accessed: - # nodered.X.X.X.X.xip.org where X.X.X.X is the IP address of IOTstack. Any other domain can be used, on that case please - # replace VIRTUAL_HOST env variable of the given instance with the coresponding value. +# As described in https://github.com/nginx-proxy/nginx-proxy. We use separate containers. +# The HTTPS implementation as documented here: https://medium.com/@francoisromain/host-multiple-websites-with-https-inside-docker-containers-on-a-single-server-18467484ab95 +# We are using xip.io to be able make subdomains for IP address. So the nodered service can be accessed: +# nodered.X.X.X.X.xip.org where X.X.X.X is the IP address of IOTstack. Any other domain can be used, on that case please +# replace VIRTUAL_HOST env variable of the given instance with the coresponding value. - nginx-proxy: - image: nginx - container_name: nginx-proxy - network_mode: host - restart: unless-stopped # Always restart container - ports: - - "80:80" # Port mappings in format host:container - - "443:443" - labels: - - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy" # Label needed for Let's Encrypt companion container - volumes: # Volumes needed for container to configure proixes and access certificates genereated by Let's Encrypt companion container - - "./volumes/nginx-proxy/nginx-conf:/etc/nginx/conf.d" - - "./volumes/nginx-proxy/nginx-vhost:/etc/nginx/vhost.d" - - "./volumes/nginx-proxy/html:/usr/share/nginx/html" - - "./volumes/nginx-proxy/certs:/etc/nginx/certs:ro" - - "./volumes/nginx-proxy/log:/var/log/nginx" +nginx-proxy: + image: nginx + container_name: nginx-proxy + network_mode: host + restart: unless-stopped # Always restart container + ports: + - "80:80" # Port mappings in format host:container + - "443:443" + labels: + - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy" # Label needed for Let's Encrypt companion container + volumes: # Volumes needed for container to configure proixes and access certificates genereated by Let's Encrypt companion container + - "./volumes/nginx-proxy/nginx-conf:/etc/nginx/conf.d" + - "./volumes/nginx-proxy/nginx-vhost:/etc/nginx/vhost.d" + - "./volumes/nginx-proxy/html:/usr/share/nginx/html" + - "./volumes/nginx-proxy/certs:/etc/nginx/certs:ro" + - "./volumes/nginx-proxy/log:/var/log/nginx" - nginx-gen: - image: ajoubert/docker-gen-arm - command: -notify-sighup nginx-proxy -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf - container_name: nginx-gen - restart: unless-stopped - volumes: - - /var/run/docker.sock:/tmp/docker.sock:ro - - "./volumes/nginx-proxy/nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro" - - "./volumes/nginx-proxy/nginx-conf:/etc/nginx/conf.d" - - "./volumes/nginx-proxy/nginx-vhost:/etc/nginx/vhost.d" - - "./volumes/nginx-proxy/html:/usr/share/nginx/html" - - "./volumes/nginx-proxy/certs:/etc/nginx/certs:ro" +nginx-gen: + image: ajoubert/docker-gen-arm + command: -notify-sighup nginx-proxy -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf + container_name: nginx-gen + restart: unless-stopped + volumes: + - /var/run/docker.sock:/tmp/docker.sock:ro + - "./volumes/nginx-proxy/nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro" + - "./volumes/nginx-proxy/nginx-conf:/etc/nginx/conf.d" + - "./volumes/nginx-proxy/nginx-vhost:/etc/nginx/vhost.d" + - "./volumes/nginx-proxy/html:/usr/share/nginx/html" + - "./volumes/nginx-proxy/certs:/etc/nginx/certs:ro" - nginx-letsencrypt: - image: budry/jrcs-letsencrypt-nginx-proxy-companion-arm - container_name: nginx-letsencrypt - restart: unless-stopped - volumes: - - /var/run/docker.sock:/var/run/docker.sock:ro - - "./volumes/nginx-proxy/nginx-conf:/etc/nginx/conf.d" - - "./volumes/nginx-proxy/nginx-vhost:/etc/nginx/vhost.d" - - "./volumes/nginx-proxy/html:/usr/share/nginx/html" - - "./volumes/nginx-proxy/certs:/etc/nginx/certs:rw" - environment: - NGINX_DOCKER_GEN_CONTAINER: "nginx-gen" - NGINX_PROXY_CONTAINER: "nginx-proxy" +nginx-letsencrypt: + image: budry/jrcs-letsencrypt-nginx-proxy-companion-arm + container_name: nginx-letsencrypt + restart: unless-stopped + volumes: + - /var/run/docker.sock:/var/run/docker.sock:ro + - "./volumes/nginx-proxy/nginx-conf:/etc/nginx/conf.d" + - "./volumes/nginx-proxy/nginx-vhost:/etc/nginx/vhost.d" + - "./volumes/nginx-proxy/html:/usr/share/nginx/html" + - "./volumes/nginx-proxy/certs:/etc/nginx/certs:rw" + environment: + NGINX_DOCKER_GEN_CONTAINER: "nginx-gen" + NGINX_PROXY_CONTAINER: "nginx-proxy" From df22faec8781a2f8a0b2cdf15134b1e2a9841692 Mon Sep 17 00:00:00 2001 From: Enrique del Pino Date: Thu, 29 Dec 2022 17:00:11 +0100 Subject: [PATCH 6/7] Formatting service.yml for nginx-proxy --- .templates/nginx-proxy/service.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.templates/nginx-proxy/service.yml b/.templates/nginx-proxy/service.yml index a44c161e..cbd638be 100755 --- a/.templates/nginx-proxy/service.yml +++ b/.templates/nginx-proxy/service.yml @@ -20,7 +20,6 @@ nginx-proxy: - "./volumes/nginx-proxy/html:/usr/share/nginx/html" - "./volumes/nginx-proxy/certs:/etc/nginx/certs:ro" - "./volumes/nginx-proxy/log:/var/log/nginx" - nginx-gen: image: ajoubert/docker-gen-arm command: -notify-sighup nginx-proxy -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf @@ -33,7 +32,6 @@ nginx-gen: - "./volumes/nginx-proxy/nginx-vhost:/etc/nginx/vhost.d" - "./volumes/nginx-proxy/html:/usr/share/nginx/html" - "./volumes/nginx-proxy/certs:/etc/nginx/certs:ro" - nginx-letsencrypt: image: budry/jrcs-letsencrypt-nginx-proxy-companion-arm container_name: nginx-letsencrypt From 39670d018e45202e9aa55051c843e79ae3266335 Mon Sep 17 00:00:00 2001 From: Enrique del Pino Date: Thu, 29 Dec 2022 17:04:08 +0100 Subject: [PATCH 7/7] Splitting nginx services in 3 --- .../{nginx-proxy => nginx-gen}/nginx.tmpl | 0 .templates/nginx-gen/service.yml | 12 +++++++++ .templates/nginx-letsencrypt/service.yml | 13 +++++++++ .templates/nginx-proxy/service.yml | 27 +------------------ 4 files changed, 26 insertions(+), 26 deletions(-) rename .templates/{nginx-proxy => nginx-gen}/nginx.tmpl (100%) create mode 100755 .templates/nginx-gen/service.yml create mode 100755 .templates/nginx-letsencrypt/service.yml diff --git a/.templates/nginx-proxy/nginx.tmpl b/.templates/nginx-gen/nginx.tmpl similarity index 100% rename from .templates/nginx-proxy/nginx.tmpl rename to .templates/nginx-gen/nginx.tmpl diff --git a/.templates/nginx-gen/service.yml b/.templates/nginx-gen/service.yml new file mode 100755 index 00000000..f51fa9e7 --- /dev/null +++ b/.templates/nginx-gen/service.yml @@ -0,0 +1,12 @@ +nginx-gen: + image: ajoubert/docker-gen-arm + command: -notify-sighup nginx-proxy -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf + container_name: nginx-gen + restart: unless-stopped + volumes: + - /var/run/docker.sock:/tmp/docker.sock:ro + - "./volumes/nginx-proxy/nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro" + - "./volumes/nginx-proxy/nginx-conf:/etc/nginx/conf.d" + - "./volumes/nginx-proxy/nginx-vhost:/etc/nginx/vhost.d" + - "./volumes/nginx-proxy/html:/usr/share/nginx/html" + - "./volumes/nginx-proxy/certs:/etc/nginx/certs:ro" diff --git a/.templates/nginx-letsencrypt/service.yml b/.templates/nginx-letsencrypt/service.yml new file mode 100755 index 00000000..3fe13855 --- /dev/null +++ b/.templates/nginx-letsencrypt/service.yml @@ -0,0 +1,13 @@ +nginx-letsencrypt: + image: budry/jrcs-letsencrypt-nginx-proxy-companion-arm + container_name: nginx-letsencrypt + restart: unless-stopped + volumes: + - /var/run/docker.sock:/var/run/docker.sock:ro + - "./volumes/nginx-proxy/nginx-conf:/etc/nginx/conf.d" + - "./volumes/nginx-proxy/nginx-vhost:/etc/nginx/vhost.d" + - "./volumes/nginx-proxy/html:/usr/share/nginx/html" + - "./volumes/nginx-proxy/certs:/etc/nginx/certs:rw" + environment: + NGINX_DOCKER_GEN_CONTAINER: "nginx-gen" + NGINX_PROXY_CONTAINER: "nginx-proxy" diff --git a/.templates/nginx-proxy/service.yml b/.templates/nginx-proxy/service.yml index cbd638be..09de2951 100755 --- a/.templates/nginx-proxy/service.yml +++ b/.templates/nginx-proxy/service.yml @@ -19,29 +19,4 @@ nginx-proxy: - "./volumes/nginx-proxy/nginx-vhost:/etc/nginx/vhost.d" - "./volumes/nginx-proxy/html:/usr/share/nginx/html" - "./volumes/nginx-proxy/certs:/etc/nginx/certs:ro" - - "./volumes/nginx-proxy/log:/var/log/nginx" -nginx-gen: - image: ajoubert/docker-gen-arm - command: -notify-sighup nginx-proxy -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf - container_name: nginx-gen - restart: unless-stopped - volumes: - - /var/run/docker.sock:/tmp/docker.sock:ro - - "./volumes/nginx-proxy/nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro" - - "./volumes/nginx-proxy/nginx-conf:/etc/nginx/conf.d" - - "./volumes/nginx-proxy/nginx-vhost:/etc/nginx/vhost.d" - - "./volumes/nginx-proxy/html:/usr/share/nginx/html" - - "./volumes/nginx-proxy/certs:/etc/nginx/certs:ro" -nginx-letsencrypt: - image: budry/jrcs-letsencrypt-nginx-proxy-companion-arm - container_name: nginx-letsencrypt - restart: unless-stopped - volumes: - - /var/run/docker.sock:/var/run/docker.sock:ro - - "./volumes/nginx-proxy/nginx-conf:/etc/nginx/conf.d" - - "./volumes/nginx-proxy/nginx-vhost:/etc/nginx/vhost.d" - - "./volumes/nginx-proxy/html:/usr/share/nginx/html" - - "./volumes/nginx-proxy/certs:/etc/nginx/certs:rw" - environment: - NGINX_DOCKER_GEN_CONTAINER: "nginx-gen" - NGINX_PROXY_CONTAINER: "nginx-proxy" + - "./volumes/nginx-proxy/log:/var/log/nginx" \ No newline at end of file