Créer un contenair Debian.
Installer le dans les règles de l'art.
Mettre les paquets à jour via :
apt update apt dist-upgrade
Installation des paquets NGINX :
apt-get install nginx
Editez le fichier /etc/nginx/nginx.conf :
user www-data; worker_processes 2; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf; events { worker_connections 1024; use epoll; } http { ## # Basic Settings ## sendfile on; tcp_nodelay on; keepalive_timeout 65; server_tokens off; types_hash_max_size 2048; server_names_hash_bucket_size 128; map_hash_bucket_size 128; include /etc/nginx/mime.types; default_type application/octet-stream; #Requete maximun par ip limit_req_zone $binary_remote_addr zone=flood:10m rate=100r/s; limit_req zone=flood burst=100 nodelay; #Connexions maximum par ip limit_conn_zone $binary_remote_addr zone=ddos:10m; limit_conn ddos 100; ## # SSL Settings ## ssl_protocols TLSv1.3 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:TLS_DHE_RSA_WITH_AES_256_GCM_SHA384; ssl_ecdh_curve secp521r1:secp384r1; ssl_session_timeout 10m; ssl_session_cache shared:SSL:10m; ssl_session_tickets off; # Requires nginx >= 1.5.9 ssl_stapling on; # Requires nginx >= 1.3.7 ssl_stapling_verify on; # Requires nginx => 1.3.7 ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt; resolver 1.1.1.1 8.8.8.8 valid=300s ipv6=off; resolver_timeout 5s; ssl_certificate /etc/letsencrypt/live/dams.ovh/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/dams.ovh/privkey.pem; ssl_dhparam /etc/letsencrypt/live/dams.ovh/dhparams.pem; ## # Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; ## # Gzip Settings ## gzip on; gzip_vary on; gzip_http_version 1.1; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; gzip_comp_level 6; gzip_min_length 1400; gzip_proxied any; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; proxy_cache_path /var/cache/nginx levels=2:2:2 keys_zone=STATIC:1000m inactive=24h max_size=1g; proxy_temp_path /var/lib/nginx/proxy; proxy_max_temp_file_size 9924m; proxy_buffering off; ## # Virtual Host Configs ## #include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; add_header X-XSS-Protection "1; mode=block"; }
Editez le fichier /etc/nginx/proxy.conf :
#parametres de forward des requetes proxy_set_header Host $host; 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 $scheme; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; #ajouter les deux lignes suivantes au cas ou il y a le warning [warn] could not build optimal proxy_headers_hash au demarage de NginX proxy_headers_hash_max_size 2048; proxy_headers_hash_bucket_size 128; #timeout avant de déclarée la page inatteignable proxy_read_timeout 900s; #version http utilisée proxy_http_version 1.1;
Editez le fichier /etc/nginx/proxy_params
proxy_set_header Host $http_host; 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 $scheme;
Puis éditez les fichiers suivant votre besoin
server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name xxx.ndd.ovh; #ssl on; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; location / { include proxy.conf; proxy_pass http://192.168.0.4:80/; ==> Ou le proxy devra pointer. } }