Created
July 14, 2024 11:59
-
-
Save alisafariir/1e6d3ee27761152d5e98f5cf8d0afdb9 to your computer and use it in GitHub Desktop.
Create Nginx Server Block Reverse Proxy With Certificate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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