Skip to content

Instantly share code, notes, and snippets.

@vadym-vorobel
Last active March 23, 2020 14:21
Show Gist options
  • Save vadym-vorobel/8461fa5d1e196aeb2c68f0e2ebd974f4 to your computer and use it in GitHub Desktop.
Save vadym-vorobel/8461fa5d1e196aeb2c68f0e2ebd974f4 to your computer and use it in GitHub Desktop.
Troubleshoots

Troubleshoots

Table of Contents


Install Nginx on Ubuntu

  1. Update packages
sudo apt-get update
  1. Install Nginx
sudo apt-get install nginx

Nginx useful commands

  • Check wether the configuration is correct
sudo nginx -t
  • Restart Nginx
sudo systemctl restart nginx.service

⇧ Back to top


Unable to access to an EC2 instance

  1. Check that a web server installed, configured and run without errors

  2. Check EC2 instance security groups. It should have a group that allows connection via port 80

  3. Check firewall. Allow connection to the port 80 (sudo ufw allow 80)

⇧ Back to top


Install Docker on Ubuntu

  1. Follow the next article

  2. Add current user to the docker group. Then logout

sudo usermod -aG docker $USER
  1. If you have an issue with logging in:
  • install additional packages
sudo apt install gnupg2 pass

⇧ Back to top


Setup Nginx website with proxy redirect to some port

  1. 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>;
  }
}
  1. Enable website
sudo ln -s /etc/nginx/sites-available/<IP_OR_DOMAIN> /etc/nginx/sites-enabled/
  1. Restart Nginx
sudo systemctl restart nginx.service

⇧ Back to top


Generate SSL certificates for Nginx on Ubuntu

Source: https://certbot.eff.org/lets-encrypt/ubuntubionic-nginx

  1. 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
  1. Install Certbot
sudo apt-get install certbot python-certbot-nginx
  1. Install certificates
sudo certbot --nginx
  1. Renew certificates
sudo certbot renew --dry-run

⇧ Back to top


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment