These instructions should work for a Debian GNU/Linux
NGINX is an http server listening by default on port 80 (http)
Would you like to setup your host to accept SSL/TSL calls on port 443 (https)
https://mywebsite.com
You should have "let's encrypt" certificate files:
/etc/letsencrypt/live/mywebsite.com/fullchain.pem
/etc/letsencrypt/live/mywebsite.com/privkey.pem
To install nginx with Linux bash command
sudo apt install nginx
to start and stop and verify http server
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl status nginx
check the server is running as www-data process.
You should find this line in /etc/nginx/nginx.conf
user www-data;
to verify your port 80 is binding with nginx
sudo netstat -plnt
your http index directory sohoud go into /var/www/
sudo mkdir /var/www/mywebsite.com
sudo chown www-data /var/www/mywebsite.com
sudo chgrp www-data /var/www/mywebsite.com
sudo chmod 775 /var/www/mywebsite.com
create a new file for website configuration in /etc/nginx/sites-available/
sudo vi /etc/nginx/sites-available/mywebsite.com
copy this configuration as the content
server {
root /var/www/mywebsite.com;
server_name *.mywebsite.com;
keepalive_timeout 70;
ssl_session_tickets on;
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/letsencrypt/live/mywebsite.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mywebsite.com/privkey.pem;
index index.html;
}
server {
return 301 https://$host$request_uri;
listen 80;
listen [::]:80;
server_name *.mywebsite.com www.mywebsite.com mywebsite.com;
return 404; # managed by Certbot
}
create a symbolic link in /etc/nginx/sites-enabled
cd /etc/nginx/sites-enabled
sudo ln -s /etc/nginx/sites-available/mywebsite.com mywebsite.com
include your username (i.e. bob) into www-data
group
usermod -a -G www-data bob
create an index file
echo "it works!" > /var/www/mywebsite.com/index.html
restart nginx http server
sudo systemctl restart nginx
make the test, open your browser and type your website url:
https://mywebsite.com