Pratique pour déployer rapidement Nginx Proxy Manager (NPM) dans Portainer en créant une pile (stack) à partir d’un fichier compose YAML.
Je pars du principe que vous maîtrisez un minimum Docker avec Portainer 😉
Nginx Proxy Manager (NPM) est un proxy inverse open source utilisé pour rediriger le trafic d’un site Web vers l’endroit approprié. L’utilisation de Nginx Proxy Manager vous permet d’utiliser une seule adresse IP publique pour héberger de nombreux services Web différents.
version: '3.8'
services:
app:
image: 'jc21/nginx-proxy-manager:latest'
restart: always
ports:
# These ports are in format <host-port>:<container-port>
- '80:80' # Public HTTP Port
- '443:443' # Public HTTPS Port
- '81:81' # Admin Web Port
# Add any other Stream port you want to expose
# - '21:21' # FTP
environment:
# Mysql/Maria connection parameters:
DB_MYSQL_HOST: "db"
DB_MYSQL_PORT: 3306
DB_MYSQL_USER: "npm"
DB_MYSQL_PASSWORD: "npm"
DB_MYSQL_NAME: "npm"
# Uncomment this if IPv6 is not enabled on your host
# DISABLE_IPV6: 'true'
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
depends_on:
- db
db:
image: 'jc21/mariadb-aria:latest'
restart: always
environment:
MYSQL_ROOT_PASSWORD: 'npm'
MYSQL_DATABASE: 'npm'
MYSQL_USER: 'npm'
MYSQL_PASSWORD: 'npm'
volumes:
- ./mysql:/var/lib/mysql
DB_MYSQL_USER: "npm"
DB_MYSQL_PASSWORD: "npm"
MYSQL_USER: 'npm'
MYSQL_PASSWORD: 'npm'
Attention de faire correspondre les variables ensemble !
Ce processus peut prendre quelques minutes selon votre machine.
Nginx Proxy Manager - Login
Nginx Proxy Manager - Dashboard
Nginx Proxy Manager - Proxy Hosts
healthcheck:
test: ["CMD", "/usr/bin/check-health"]
interval: 10s
timeout: 3s
...
environment:
X_FRAME_OPTIONS: "sameorigin"
...
volumes:
...
- ./logrotate.custom:/etc/logrotate.d/nginx-proxy-manager
Pour référence, la configuration par défaut est :
/data/logs/*_access.log /data/logs/*/access.log {
su npm npm
create 0644
weekly
rotate 4
missingok
notifempty
compress
sharedscripts
postrotate
kill -USR1 `cat /run/nginx/nginx.pid 2>/dev/null` 2>/dev/null || true
endscript
}
/data/logs/*_error.log /data/logs/*/error.log {
su npm npm
create 0644
weekly
rotate 10
missingok
notifempty
compress
sharedscripts
postrotate
kill -USR1 `cat /run/nginx/nginx.pid 2>/dev/null` 2>/dev/null || true
endscript
}
Cette configuration est disponible ICI.
load_module /usr/lib/nginx/modules/ngx_http_geoip2_module.so;
load_module /usr/lib/nginx/modules/ngx_stream_geoip2_module.so;
services:
npm:
image: 'jc21/nginx-proxy-manager:latest'
container_name: npm
restart: always
ports:
# These ports are in format <host-port>:<container-port>
- '80:80' # Public HTTP Port
- '443:443' # Public HTTPS Port
- '81:81' # Admin Web Port
# Add any other Stream port you want to expose
# - '21:21' # FTP
environment:
# Uncomment this if you want to change the location of
# the SQLite DB file within the container
# DB_SQLITE_FILE: "/data/database.sqlite"
# Uncomment this if IPv6 is not enabled on your host
# DISABLE_IPV6: 'true'
# X-FRAME-OPTIONS Header
X_FRAME_OPTIONS: "sameorigin"
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
- ./logrotate.custom:/etc/logrotate.d/nginx-proxy-manager
healthcheck:
test: ["CMD", "/usr/bin/check-health"]
interval: 10s
timeout: 3s
Fichier compose également disponible sur ByteStash Blabla Linux.