Skip to content

Instantly share code, notes, and snippets.

@alisafariir
Created July 14, 2024 11:59
Show Gist options
  • Save alisafariir/1e6d3ee27761152d5e98f5cf8d0afdb9 to your computer and use it in GitHub Desktop.
Save alisafariir/1e6d3ee27761152d5e98f5cf8d0afdb9 to your computer and use it in GitHub Desktop.
Create Nginx Server Block Reverse Proxy With Certificate
sudo mkdir -p /var/www/example.com
sudo chown -R $USER:$USER /var/www/example.com
sudo chmod -R 755 /var/www
sudo nano /etc/nginx/sites-available/example.com
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
location / {
proxy_pass http://127.0.0.1:4000;
include proxy_params;
}
}
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo certbot --nginx -d example.com -d www.example.com
sudo nginx -t
sudo systemctl restart nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment