Manually add SSL certificate ServerPilot
ServerPilot uses Nginx as the public facing web server and proxies the requests to Apache. So, we have to add our SSL configuration to Nginx. Steps: Login to the server using SSH Create a directory to hold the certificate and key files.
cd /home
mkdir -p certs/domain_name
Copy the certificate (.crt) and private (.key) files to this directory. Replace domain_name with your domain name. Add custom SSL configuration here:
cd /etc/nginx-sp/vhosts.d
nano APP_NAME.ssl.conf
Replace APP_NAME with your actual app name (website). Put this inside the file APP_ NAME.ssl.conf:
###############################################################################
# Install SSL Certificate
###############################################################################
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name
www.DOMAIN.com
DOMAIN.com
;
ssl on;
ssl_certificate /home/certs/domain_name/certificate_file.crt;
ssl_certificate_key /home/certs/domain_name/privatekey_file.key;
root /srv/users/serverpilot/apps/APP_NAME/public;
access_log /srv/users/serverpilot/log/APP_NAME/APP_NAME_nginx.access.log main;
error_log /srv/users/serverpilot/log/APP_NAME/APP_NAME_nginx.error.log;
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-SSL on;
proxy_set_header X-Forwarded-Proto $scheme;
include /etc/nginx-sp/vhosts.d/APP_NAME.d/*.nonssl_conf;
include /etc/nginx-sp/vhosts.d/APP_NAME.d/*.conf;
}
As usual, replace APP_NAME, domain_name, certificate_file and privatekey_file with your own values. Restart Nginx
service nginx-sp restart
That’s it. The SSL certificate is installed. There is also a nifty script made by Lesaff on Github that does this for you: Bash script to generate and install Let’s Encrypt certificate for your websites on your ServerPilot account (Free or Paid Plan)