- Update packages
sudo apt-get update
- Install Nginx
sudo apt-get install nginx
- Check wether the configuration is correct
sudo nginx -t
- Restart Nginx
sudo systemctl restart nginx.service
-
Check that a web server installed, configured and run without errors
-
Check EC2 instance security groups. It should have a group that allows connection via port 80
-
Check firewall. Allow connection to the port 80 (
sudo ufw allow 80
)
-
Follow the next article
-
Add current user to the
docker
group. Then logout
sudo usermod -aG docker $USER
- If you have an issue with logging in:
- install additional packages
sudo apt install gnupg2 pass
- Create Nginx configuration file.
Nginx configuration files should be place in the directory /etc/nginx/sites-available/
. The name of a configuration file should be the same as server public IP address or a domain name (without www
or protocol, but may be with sub domain name).
Example configuration
server {
listen 80;
listen [::]:80;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name <IP_OR_DOMAIN> [www.<DOMAIN>];
location / {
proxy_pass http://localhost:<PORT>;
}
}
- Enable website
sudo ln -s /etc/nginx/sites-available/<IP_OR_DOMAIN> /etc/nginx/sites-enabled/
- Restart Nginx
sudo systemctl restart nginx.service
Source: https://certbot.eff.org/lets-encrypt/ubuntubionic-nginx
- Add Certbot PPA
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository universe
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
- Install Certbot
sudo apt-get install certbot python-certbot-nginx
- Install certificates
sudo certbot --nginx
- Renew certificates
sudo certbot renew --dry-run