NGINX Installation
This guide assumes you already have an Ubuntu server set up and running. SSH into your server and confirm that you have sudo privileges before proceeding with the installation of NGINX.
Navigation:
- Installation
- Cloud Firewall Configuration
- NGINX Configuration
- SFTP Access Setup
- Default File Locations
Installation
Update your system:
sudo apt update && sudo apt upgrade -y
Install NGINX:
sudo apt install nginx -y
Confirm the service is now running:
sudo systemctl status nginx
Allow the NGINX service through your firewall:
sudo ufw allow 'Nginx Full'
Confirm this change:
sudo ufw status numbered
Confirm NGINX is working independent of the network:
curl -I http://localhost
You should see a response similar to:
HTTP/1.1 200 OK
Server: nginx/1.24.0 (Ubuntu)
Date: Mon, 04 May 2026 23:23:12 GMT
Content-Type: text/html
Content-Length: 615
Last-Modified: Mon, 04 May 2026 23:09:09 GMT
Connection: keep-alive
ETag: "13f69007-666"
Accept-Ranges: bytes
Cloud Firewall Configuration
If you are hosting on a cloud provider, you need to ensure the cloud firewall allows HTTP and HTTPS traffic. In this example, Linode is used.
Log in to your Linode Dashboard. Expand Networking on the left, then tap Firewalls.
Select your instance.
On the next page, tap the button for Add An Inbound Rule.
Complete the form. Ensure you have set the Action to Accept. Then tap the Add Rule button.
This will need to be completed for HTTP, HTTPS, and SSH if you set an SSH port other than 22. Once this has been completed, tap the Save Changes button.
It will take a few minutes for the changes to take effect.
Confirm NGINX is now accessible from your browser. Open your browser, enter the IP address of your server in the URL prompt, then hit enter. You should be presented with the default NGINX splash page.
NGINX Configuration
There are some configuration changes that may need to be made to ensure NGINX runs properly.
The Basics
Enable NGINX on boot:
sudo systemctl enable nginx
Allow OpenSSH:
sudo ufw OpenSSH
Domain DNS
You will need your domain to be directed to your server IP. Otherwise, public users will be stuck memorizing a string of numbers instead of an easily remembered name. This process will vary based on your domain and cloud providers.
Log in to your domain provider. Select the appropriate option to manage your domain. Then select the appropriate option to manage your DNS. Create an A Record.
Type: A
Name: @
Value: your-server-ip-address
TTL: Auto or 24 Hours
Create an A Record for WWW.
Type: A
Name: www
Value: your-server-ip-address
TTL: Auto or 24 Hours
If any AAAA records already exist, delete them.
To test propagation, open your local terminal. Then ping your domain. Ensure the pings are returning the correct server IP address.
ping -t sitename.domain
ping -t www.sitename.domain
On your web server, confirm HTTP is working with the new domain name:
curl http://tonyalonso.tech
Enable HTTPS
It is important to encrypt traffic between the browser and your web server to prevent eavesdropping and tampering. In this example, Let's Encrypt is used as the certificate authority, with Certbot automating the process of obtaining, installing, and renewing SSL/TLS certificates.
As a prerequisite, ensure Python is already installed.
sudo apt install python3
Install Certbot:
sudo apt install certbot python3-certbot-nginx -y
Run Certbot:
sudo certbot --nginx
Follow the prompts. Once the steps have completed, visit your domain in the browser. You should now see that you are connecting over HTTPS instead of HTTP.
Confirm auto-renew will work successfully:
sudo certbot renew --dry-run
SFTP Access Setup
Now that your web server is facing the open internet, it is important to make sure it is secure.
Create a FTP User
Create the user on the Ubuntu Server. Ensure the username is unique and the password is secure:
sudo adduser ftpuser
Give the user ownership of the html directory:
sudo chown -R ftpuser:ftpuser /var/www/html
Set permissions for the html folder:
sudo chmod 755 /var/www/html
Restrict the user's access to only this directory and subdirectories:
sudo nano /etc/ssh/sshd_config
Add this to the bottom, making the appropriate changes:
Match User ftpuser
ChrootDirectory /var/www/html
ForceCommand internal-sftp
AllowTcpForwarding no
X11Forwarding no
CTRL+O to save, and CTRL+X to close.
Restart SSH:
sudo systemctl restart ssh
Ensure the ssh port is allowed through the firewall for TCP traffic:
sudo ufw allow ssh-port-#/tcp
Reload the firewall:
sudo ufw reload
Attempt utilizing your FTP client. Ensure you have configured the below settings:
Protocol: SFTP
Host: server-ip-address
User: ftpuser@server-ip-address
Port: ssh-port-#(usually 22)
Default remote directory: /var/www/html
Attempt connecting to your site with your FTP Client to confirm setup completed successfully.
Default File Locations
Main Config:
/etc/nginx/nginx.conf
Configuration files for all available sites:
/etc/nginx/sites-available/
Symbolic links for active sites:
/etc/nginx/sites-enabled/
Default web root:
/var/www/html
Access Logs:
/var/log/nginx/access.log
Error Logs:
/var/log/nginx/error.log