$ sudo apt install nginx$ sudo nano /etc/nginx/sites-available/your_domainreplace the config with this:
- for static
server {
listen 80;
server_name your_domain.com;
location / {
root /path/to/your/vue/project/dist;
index index.html;
try_files $uri $uri/ /index.html;
}
}- for reverse proxy
server {
listen 80;
server_name your_domain.com;
location / {
proxy_pass http://localhost:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}link the conf
sudo ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled/don't forget to verify the nginx config is valid & no error
$ sudo nginx -tif your project is static web, dont forget to make your project folder permission accessed, in this case i'm using vue 2 js project
$ ls -ld /home/your_username/ /home/your_username/your_project/
$ sudo chmod 755 /home/your_username/ /home/your_username/your_project/
$ sudo -u www-data ls /home/your_username/your_project/dist
$ sudo chmod -R 777 /home/your_username/your_project/dist
$ sudo chown -R www-data:www-data /home/your_username/your_project/distthen restart or start the nginx
$ sudo service nginx restart # or sudo service nginx startin this case im using ubuntu 22.04
$ sudo apt install certbot python3-certbot-nginxafter finish verify if certbot install
$ certbot --versionrun cerbot for generate the certificate ssl
$ sudo certbot --nginx -d your_domaincertbot automatic set the ssl config in nginx config
then make sure if nginx config no error
$ sudo nginx -tafter that restart the nginx
$ sudo service nginx restartthat all, now u can access your web with https