Skip to content

Instantly share code, notes, and snippets.

@masasdani
Last active November 2, 2021 15:23
Show Gist options
  • Save masasdani/42387be51e84a41b7c7d04c8582ecc6a to your computer and use it in GitHub Desktop.
Save masasdani/42387be51e84a41b7c7d04c8582ecc6a to your computer and use it in GitHub Desktop.
install-nginx-amazon-linux

install nginx

sudo amazon-linux-extras list | grep nginx
sudo amazon-linux-extras enable nginx1
sudo yum clean metadata
sudo yum -y install nginx
nginx -v

start and set default

sudo service nginx start
sudo chkconfig nginx on

install certbot

sudo amazon-linux-extras install epel
sudo yum install certbot python2-certbot-nginx

nginx .conf

/etc/nginx/cond.d/yourdomain.conf

server {
    server_name yourdomain.com;
    location / {
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host    $host;
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://localhost:3001;
    }
    listen 80;
}

generate ceritifate

sudo certbot --nginx -d yourdomain.com

enable auto renew

sudo crontab -e
0 10 * * * /usr/bin/certbot renew --quiet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment