sudo apt install nginx -y
sudo ufw allow 'Nginx full'
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt
..........+..+..........+...........+.......+...............+++++++++++++++++++++++++++++++++++++++*...+++++++++++++++++++++++++++++++++++++++*.........+.....+...............+.+...+......+...+..+.........+.......+...+..+.......+..+.+...............+............+..+...+...+.......+......+...........+.+...+..+.........+....+.........+...+..+...+............+.+......+.....+.+........+............+....+.....+.+........+.......+.....+.......+.....+.+..+...+.+..............+....+..+..........+.....+......+.................................+.......+..+..................+....+.........+......+.....+.........+.........+...+....+...+........+...+....+...+.....+.......+......+...............+..............+...............+.+.....+.........+............+......+....+.........+.........+..+.+.....+....+.....+...+.............+.........+.....+....+......+..............+.+........+...+.........................+..+.......+.......................+.......+.........+......+.....+.+.....+...++++++
...+.......+...+............+..+......+.+.....+...+.+++++++++++++++++++++++++++++++++++++++*....+.........+..+...+.........+...+...+....+...+............+...+...+..+....+...+..+++++++++++++++++++++++++++++++++++++++*....+....+..+...+....+......+......+...+.....+.+.....+.......++++++
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:
server {
# This block need for redirecting HTTP to HTTPS
# When Nginx receive client request on 80 port by HTTP
# Connection will be redirected on HTTPS
listen 80;
server_name your-project.com www.your-project.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name your-project.com www.your-project.com;
# Certificates PATH:
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
# Setting up reverse proxy to application side
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://localhost:8000;
}
}
sudo ln -s /etc/nginx/sites-available/your-project.com /etc/nginx/sites-enabled
sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
sudo systemctl restart nginx
Your connection is not private
Attackers might be trying to steal your information from your-project.com (for example, passwords, messages, or credit cards). Learn more
NET::ERR_CERT_AUTHORITY_INVALID