sudo apt install certbot python3-certbot-nginx
sudo certbot certonly --manual \
-d *.example.com -d example.com \
--agree-tos \
--manual-public-ip-logging-ok \
--preferred-challenges dns-01 \
--server https://acme-v02.api.letsencrypt.org/directory \
--register-unsafely-without-email \
--rsa-key-size 4096
server {
listen 80;
listen [::]:80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com *.example.com;
root /var/www/example.com/public;
index index.html index.php;
ssl_certificate /etc/letsencrypt/live/example.com/chain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $fastcgi_script_name =404;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\.ht {
deny all;
}
}
sudo openssl pkcs12 -export \
-out /var/lib/plexmediaserver/certificate.p12 \
-in /etc/letsencrypt/live/plex.example.com/cert.pem \
-inkey /etc/letsencrypt/live/plex.example.com/privkey.pem \
-certfile /etc/letsencrypt/live/plex.example.com/chain.pem \
-passout pass:PASSWORD \
-certpbe AES-256-CBC -keypbe AES-256-CBC -macalg SHA256
sudo chown plex:plex /var/lib/plexmediaserver/certificate.p12