nginx server with https

Ubuntu 24.04

Setting up a webserver is quite straightforward.

1- install nginx

apt update
apt install nginx -y

2- create and open config file

vi /etc/nginx/conf.d/mydomain.conf

3- paste this into the config file

server {
  server_name mydomain.com; // your FQDN here
  root /opt/www; // root path of the webserver

  location / {
  }

  listen [::]:80; // delete if you don't have ipv6
  listen 80;
}

4- start webserver and test

systemctl restart nginx

Open http://mydomain.com in your browser to see if it works. If not, check firewall and logs.

5- install certbot and config https

apt install python3-certbot-nginx
certbot --nginx -d mydomain.com

Certbot will request the certificate and create a cron job for automatic renewal.

6- see what certbot did

cat /etc/nginx/conf.d/mydomain.conf

Notice certbot added some stuff for the ssl part.

Open https://mydomain.com in your browser to see if ssl works.

Need a proxy server? Check out this one.

-jer


You'll only receive email when they publish something new.

More from jertaa
All posts