home
nginx-cheatsheet.md

nginx Cheatsheet

2022-07-31

Setting up a static site in nginx.

Step 1: Create the config file

/etc/nginx/sites-available/new-site.conf

server {
    listen 443;
    server_name new-site.dev;
    root /path/to/folder/new-site;
}

Step 2: Symlink the config

# ln -s /etc/nginx/sites-available/new-site.conf /etc/nginx/sites-enabled/

Step 3: Trigger certbot to get SSL certificates

# certbot --nginx

This will add some extra configuration to the nginx file.

Step 4: Restart nginx

# service nginx restart