Install Nginx using bash script on Ubuntu

From PKC
Revision as of 04:27, 7 July 2021 by Benkoo (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Before installation, make sure that you first create the following file:reverse-proxy.conf, located in the sub-directory ./resource/.

server {
    listen 80;
    location / {
        proxy_pass http://localhost:32001;
    }
}

For automated installation of Nginx and Letsencrypt on Ubuntu 20.04. See the following code:

#! /bin/bash

apt-get update
apt-get install nginx -y

unlink /etc/nginx/sites-enabled/default

cp ./resources/reverse-proxy.conf /etc/nginx/sites-available/.

ln -s /etc/nginx/sites-available/reverse-proxy.conf /etc/nginx/sites-enabled/reverse-proxy.conf

add-apt-repository ppa:certbot/certbot -y

apt install -y python3-certbot-nginx

nginx -t

systemctl reload nginx