How to install certbot on UBUNTU 16, certificate for Nginx only

Practice



If you get errors like

Certbot: command not found

or

Unable to find certbot package

1 . to fix this, install certbot

apt-get install software-properties-common (only for old ubuntu versions that don't have the add-apt-repository command)

sudo add-apt-repository ppa:certbot/certbot (only for old ubuntu versions that don't have the certbot repository)

sudo apt-get update
sudo apt-get install --upgrade letsencrypt

certbot register --email email@gmail.com
certbot certonly -d domain.com -d www.domain.com

2. then enter the path to the site's root

How would you like to authenticate with the ACME CA?
-------------------------------------------------------------------------------
1: Spin up a temporary webserver (standalone)
2: Place files in webroot directory (webroot)

choose 2


1: Enter a new webroot

for example /var/www/domain/public_html/public

agree and select this path

3. connect the generated certificate in nginx

in the config file

/etc/nginx/sites-enabled/domain.com.nginx.conf

do the following

upstream stream_domain {

# Back-end address

server localhost:8989;

}

server {

listen 443;

server_name domain.com www.domain.com ;

ssl on;

# ssl_certificate /etc/ssl/sslnginx/public_concat.crt;

# ssl_certificate_key /etc/ssl/sslnginx/domain_com.key;

ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem;

ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem;

ssl_trusted_certificate /etc/letsencrypt/live/domain.com/chain.pem;

#SSLCertificateChainFile /etc/ssl/ssl.crt/domain_com.ca-bundle;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

ssl_prefer_server_ciphers on;

ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:AES128-SHA:RC4-SHA;

ssl_session_cache shared:SSL:10m;

add_header Strict-Transport-Security max-age=31536000;

access_log /var/www/domain.com/logs/nginx_ssl_access.log;

error_log /var/www/domain.com/logs/nginx_ssl_error.log;

# Redirect to back-end

location / {

proxy_pass http://stream_domain;

include /etc/nginx/proxy_params;

}

client_max_body_size 300m;

client_body_buffer_size 128k;

proxy_connect_timeout 75s;

proxy_send_timeout 360s;

proxy_read_timeout 1200s;

proxy_set_header X-Forwarded-Proto $scheme;

# Static content is served by nginx itself

# the back-end should not handle this

location ~* \.(css|ico|swf|js|jpeg|jpg|bmp|gif|mp4|png)$ {

root /var/www/domain.com/public_html/public;

#etag on;

expires 100d;

#proxy_ignore_headers Cache-Control;

#add_header Cache-Control "max-age=604800";

access_log off;

}

}

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Running server side scripts using PHP as an example (LAMP)"

Terms: Running server side scripts using PHP as an example (LAMP)