/etc/nginx/sites-enabled/domain.conf должен быть симлинком на
/etc/nginx/sites-available/domain.conf, а не его копией.
Если не умеешь делать симлинки оставь только конфиг в
/etc/nginx/sites-enabled/domain.conf
Убедись, что в
/etc/nginx/nginx.conf есть
include /etc/nginx/sites-enabled/*.conf;
Конфиг сделай таким:
server {
listen 80;
server_name domain;
location /.well-known/acme-challenge/ {
alias /path/to/.well-known/acme-challenge/;
allow all;
default_type "text/plain";
try_files $uri =404;
}
location / {
return 301 https://domain$request_uri;
}
}
Получи сертификат:
certbot certonly --agree-tos --email webmaster@domain --webroot -w /path/to/ -d domain
Сгенерируй dhparam
openssl dhparam -out /etc/nginx/dhparam4096.pem 4096
Затем добавь конфиг для https версии:
server {
listen 443 ssl http2;
server_name domain;
ssl_certificate /etc/letsencrypt/live/domain/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain/privkey.pem;
ssl_dhparam /etc/nginx/dhparam4096.pem;
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;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ecdh_curve secp384r1:prime256v1:X25519;
ssl_session_timeout 24h;
ssl_session_cache shared:TLS:20m;
resolver 1.1.1.1 8.8.8.8;
resolver_timeout 5s;
ssl_stapling on;
ssl_stapling_verify on;
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection ‘upgrade’;
proxy_cache_bypass $http_upgrade;
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_pass URL;
- протокол тоже
надо указывать.