Nginx is a 'high-performance web server and a reverse proxy server'. This is what is behind the /var/www/html
directories I've seen in others' projects.
SERVER CONFIG
/var/www/html
: actual web content (defaults as Nginx server page)
/etc/nginx
: nginx config directory
/etc/nginx/nginx.conf
: main config file
/etc/nginx/sites-available/
: "server blocks" are stored here. Nginx will not use the the files in this directory unless they are linked to sites-enabled
directory.
/etc/nginx/sites-enabled/
: Enabled "server blocks" are stored here. Linked to config files within sites-available
dir.
/etc/nginx/snippets
: contains config fragments that can be used throughout the nginx config, such as repeated config segments.
SERVER LOGS
/var/log/nginx/access.log
: every request to your web server is recorded in this log file unless nginx is configured otherwise.
/var/log/nginx/error.log
: any nginx errors
# on a deploy (non-root) user && after a basic firewall has been configured
sudo apt-get update
sudo apt-get install nginx
# adjust the firewall
# sudo ufw app list will show you that NGINX has 3 available apps
# Nginx Full: This profile opens both port 80 (normal, unencrypted web traffic)
# and port 443 (TLS/SSL encrypted traffic)
# Nginx HTTP: This profile opens only port 80 (normal, unencrypted web traffic)
# Nginx HTTPS: This profile opens only port 443 (TLS/SSL encrypted traffic)
# It is recommended that you enable the most restrictive profile that will still
# allow the traffic you've configured. Since we haven't configured SSL for our
# server yet, in this guide, we will only need to allow traffic on port 80.
sudo ufw allow 'Nginx HTTP'
sudo ufw status
# check nginx status
systemctl status nginx
# to stop nginx web server
sudo systemctl stop nginx
# to start nginx web server
sudo systemctl start nginx
# to restart nginx web server
sudo sysstemctl restart nginx
# reload without dropping connections (when making changes to nginx config)
sudo systemctl reload nginx
# to change nginx auto start on server start
sudo systemctl [enable/disable] nginx