Skip to content

Instantly share code, notes, and snippets.

@emondarock
Last active September 22, 2024 09:09
Show Gist options
  • Save emondarock/f797e878897f020372f56d319d90189d to your computer and use it in GitHub Desktop.
Save emondarock/f797e878897f020372f56d319d90189d to your computer and use it in GitHub Desktop.
AWS SSL configuration with nodejs, nginx and letsencrypt using certbot
1) Clone Repo
2) Install all module by `sudo npm install`. After installing all modules if u get any error run `npm rebuild`
2) Install pm2 by running `sudo npm i pm2 -g`
4) run via pm2 `pm2 start pm2-config.json`
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get install python-certbot-nginx
sudo nano /etc/nginx/sites-available/yourdomain.com.conf
And copy the following
server {
listen 80;
server_name <YourDomain.com>; ##Change domain as u need
location / {
proxy_pass http://localhost:3005; ##Change your port as u need
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Follow the command
sudo nano /etc/nginx/nginx.conf
Change
inculde /etc/nginx/sites-enabled/*;
to
include /etc/nginx/sites-available/*;
Change example.com and <YourDomain.com> to your domain
Change proxy_pass http://localhost:3000/ to your desired port
Check nginx conf
sudo nginx -t
Restart nginx
sudo service nginx stop
sudo service nginx start
sudo certbot --nginx
select your domain
redirect all routing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment