serversetups/nginx-setup.md

1.1 KiB

Nginx Setups

Sources:

Nginx Beginners Guide Nginx Config Example

1. Installation

If not installed, execute this:

sudo apt install nginx certbot python3-certbot-nginx

2. create nginx config

To create a config execute:

touch /etc/nginx/sites-available/[SUBDOMAIN].[DOMAIN]

Copy from the default config And paste it after executing:

nano /etc/nginx/sites-available/[SUBDOMAIN].[DOMAIN]

Dont forget to replace [PLACEHOLDERS]

Softlink to sites-enabled

sudo ln -s /etc/nginx/sites-available/[SUBDOMAIN].[DOMAIN] /etc/nginx/sites-enabled/

3. Check and restart nginx

Test the new config with this command:

sudo nginx -t

If successful execute

sudo systemctl restart nginx

4. Get https certificate

In Cloudflare or another dns manager add an a record to the ip for creating a sub domain.

After that certify the subdomain with this command.

sudo certbot --nginx -d [SUBDOMAIN].[DOMAIN]