Nginx
Overview
NGINX is a high-performance web server, reverse proxy and load balancer. It is known for its stability, low resource consumption and ability to handle a large number of concurrent connections.
This guide shows you how to deploy and configure NGINX on Linux from the SecureAnyCloud AMI on the AWS Marketplace.
What you get:
- The NGINX web server with the default configuration on port 80
- A preconfigured systemd service that starts NGINX automatically on boot
- The default web root at /usr/share/nginx
- An OS package update script that keeps the system current
- AWS CLI v2 for AWS service integration
- Systems Manager Agent (SSM) for remote management
- CloudWatch Agent for monitoring
- The latest security patches, applied at build time
- 24/7 SecureAnyCloud support with a guaranteed 24-hour response SLA
Prerequisites
Before you launch this AMI, you need:
- An active AWS account
- An active subscription to the NGINX listing on AWS Marketplace
- An EC2 key pair for SSH access
- Familiarity with EC2 instance management and SSH
Recommended instance type: t3.small (2 vCPU, 2 GB RAM) or larger. The minimum requirements are 1 vCPU, 1 GB RAM and 20 GB of disk space. NGINX is lightweight and performs well even on smaller instances.
Launch the AMI
- Go to the AWS Marketplace and search for "NGINX SecureAnyCloud".
- Choose Continue to Subscribe, accept the terms, then choose Continue to Configuration.
- Select your preferred Region and Software Version.
- Choose Continue to Launch.
- Choose Launch through EC2 for full control over the instance configuration.
- Select your instance type (
t3.smallrecommended). - Configure storage with a minimum of 20 GB gp3.
- Configure your Security Group with the following inbound rules.
Port Protocol Source Purpose
22 TCP Your IP SSH access
80 TCP 0.0.0.0/0 NGINX web server (HTTP)
443 TCP 0.0.0.0/0 NGINX web server (HTTPS, if configured)
Select your EC2 key pair and launch the instance.
Connect over SSH
Once your instance is running and has passed both status checks (2/2), connect over SSH:
ssh -i your-key.pem ec2-user@<public-ip-address>Replace your-key.pem with the path to your EC2 key pair and <public-ip-address> with your instance's public IP address.
Important: Wait for the instance to reach 2/2 successful status checks before you connect. If you connect too early, you may see errors such as:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).These errors are expected during the initial boot. Wait for both status checks to pass, then try again.
To switch to the root user, run:
sudo su -Verify NGINX is running
NGINX starts automatically on boot. Verify that the service is running:
systemctl status nginxOpen your web browser and go to:
http://<public-ip-address>:80You should see the default NGINX welcome page, which confirms that the server is running and accessible.
Deploy your website
The default web root is /usr/share/nginx/html. To deploy your own content, replace the files in this directory.
Upload files with SCP:
scp -i your-key.pem -r ./my-website/* ec2-user@<public-ip-address>:/tmp/Then move the files to the web root:
sudo cp -r /tmp/my-website/* /usr/share/nginx/html/Set the correct permissions:
sudo chown -R nginx:nginx /usr/share/nginx/html/
sudo chmod -R 755 /usr/share/nginx/html/Configure virtual hosts
To serve multiple websites from a single NGINX instance, create server block configuration files.
Create a new server block:
sudo vi /etc/nginx/conf.d/mysite.confExample server block configuration:
server { listen 80; server_name mysite.example.com; root /var/www/mysite; index index.html; location / { try_files $uri $uri/ =404; } access_log /var/log/nginx/mysite_access.log; error_log /var/log/nginx/mysite_error.log; }Test the configuration and reload:
sudo nginx -t sudo systemctl reload nginxConfigure a reverse proxy
NGINX is commonly used as a reverse proxy that forwards requests to application servers.
Example reverse proxy configuration:
sudo vi /etc/nginx/conf.d/proxy.confserver { listen 80; server_name app.example.com; location / { proxy_pass http://127.0.0.1:3000; 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_set_header X-Forwarded-Proto $scheme; } }sudo nginx -t sudo systemctl reload nginxServer components
Component Install Path
NGINX /etc/nginx
Note: The automatic OS package update script may update component versions on first boot.
Filesystem layout
Mount Point Size Description
/ 38 GB Root filesystem
/boot 2 GB Operating system kernel files
/usr/share/nginx 9.8 GB NGINX web server root
Key NGINX directories:
Directory Purpose
/etc/nginx Main configuration directory
/etc/nginx/nginx.conf Primary configuration file
/etc/nginx/conf.d/ Additional server block configurations
/usr/share/nginx/html Default web root
/var/log/nginx Access and error logs
/var/cache/nginx Cached content
Manage the NGINX service
systemd manages NGINX, and it starts automatically on boot.
Check service status:
systemctl status nginxStop NGINX:
systemctl stop nginxStart NGINX:
systemctl start nginxRestart NGINX:
systemctl restart nginxReload configuration without downtime:
systemctl reload nginxTest configuration syntax:
nginx -tScripts and log files
Script/Log Path Description
initial_boot_update.sh /stage/scripts Updates the OS with the latest packages on first boot
initial_boot_update.log /stage/scripts Output log for the boot update script
NGINX logs:
Log File Path Description
access.log /var/log/nginx/access.log HTTP request log
error.log /var/log/nginx/error.log Error and diagnostic log
On startup
An OS package update script runs on first boot to bring the image fully up to date. To disable it, remove the script and its crontab entry:
rm -f /stage/scripts/initial_boot_update.sh crontab -e
# Delete the following line, save and exit: @reboot /stage/scripts/initial_boot_update.shTroubleshooting
You cannot reach NGINX on port 80
- Verify that NGINX is running:
systemctl status nginx - Check that your security group allows inbound traffic on port 80
- Ensure that the instance has passed 2/2 status checks
- Check the error logs:
tail -f /var/log/nginx/error.log
The configuration test fails
- Run
nginx -tto see the exact error and line number - Look for common issues: missing semicolons, unclosed brackets and duplicate
server_namevalues - Check for syntax errors in the files under
/etc/nginx/conf.d/
You get a 403 Forbidden error
- Check file ownership. Files should be owned by
nginx:nginx - Check directory permissions. Directories need 755 and files need 644
- Verify that the
rootdirective in your server block points to the correct path - Check SELinux with
getenforce. If it is enforcing, adjust the contexts withchcon -R -t httpd_sys_content_t /var/www/mysite
You get a 502 Bad Gateway error (when using NGINX as a reverse proxy)
- Verify that the backend application is running on the expected port
- Check that the
proxy_passURL is correct - Review the NGINX error logs:
tail -f /var/log/nginx/error.log
Security recommendations
- Enable HTTPS. Install an SSL certificate from Let's Encrypt (
certbot) or use your own certificate - Hide the server version. Add
server_tokens off;to thehttpblock in/etc/nginx/nginx.conf - Restrict sensitive paths. Use
locationblocks withdeny allfor admin areas - Enable rate limiting. Use
limit_req_zoneto protect against brute-force attacks - Configure security headers. Add headers such as
X-Content-Type-Options,X-Frame-OptionsandContent-Security-Policy - Keep NGINX updated. Update regularly with
yum update nginx - Monitor access logs. Review
/var/log/nginx/access.logfor suspicious requests - Use firewall rules. Restrict SSH access to your IP address and open only the ports you need
Support
If you have any issues with this product, contact SecureAnyCloud support:
- Email: sales@secureanycloud.com
- Website: secureanycloud.com
- Support hours: 24/7, with a guaranteed 24-hour response SLA
Deploy on AWS
Launch NGINX with 24/7 support from SecureAnyCloud.
View on Marketplace
Need Help?
Our support team is available 24/7.
sales@secureanycloud.com
NGINX Open Source is a high-performance web server and reverse proxy, installed from the official nginx.org repository. This guide shows you how to connect to your instance, verify the server, deploy your own site, enable the reverse-proxy starter and configure HTTPS with Let's Encrypt.
Prerequisites
- An AWS account with permission to launch EC2 instances
- A subscription to the NGINX Open Source AMI on AWS Marketplace
- An SSH key pair that you associate with the instance at launch
Connect to your instance
OS variant SSH login user
Ubuntu 24.04 ubuntu
ssh -i /path/to/your-key.pem ubuntu@<instance-public-ip>Once connected, verify that NGINX is running:
nginx -vnginx version: nginx/1.31.1systemctl status nginx --no-pager● nginx.service - nginx - high performance web server Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: enabled) Active: active (running) since Wed 2026-05-27 17:37:37 UTC; 8s ago Docs: https://nginx.org/en/docs/ Process: 3357 ExecStart=/usr/sbin/nginx -c ${CONFFILE} (code=exited, status=0/SUCCESS) Main PID: 3358 (nginx) Tasks: 3 (limit: 4520) Memory: 2.9M (peak: 3.5M) CPU: 11ms CGroup: /system.slice/nginx.service ├─3358 "nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf" ├─3359 "nginx: worker process" └─3360 "nginx: worker process"Confirm the default landing page
Browse to http://<instance-public-ip>/, or run this command from the instance:
curl -si http://127.0.0.1/ | head -10HTTP/1.1 200 OK Server: nginx Date: Wed, 27 May 2026 17:37:46 GMT Content-Type: text/html Content-Length: 2591 Last-Modified: Wed, 27 May 2026 17:35:55 GMT Connection: keep-alive ETag: "6a172b7b-a1f" Accept-Ranges: bytesThe SecureAnyCloud default landing page confirms that the server is healthy and shows where the document root is.
Instance information file
On first boot, nginx-firstboot.service writes a summary file. Read it with:
sudo cat /root/nginx-info.txt# NGINX Open Source — written on first boot by nginx-firstboot.service.
# This file holds no secrets; NGINX itself is unauthenticated. It is an
# informational summary only. nginx.version=1.31.1 nginx.document.root=/var/www/html nginx.config.root=/etc/nginx nginx.landing.page=http://172.31.81.113/
# Monitoring (reachable from this instance only, by default):
# http://127.0.0.1/nginx_status live connection / request counters
#
# Place your website files in /var/www/html. To enable the reverse-proxy starter,
# rename /etc/nginx/conf.d/sample.conf.disabled to sample.conf, edit the
# upstream, run nginx -t, then systemctl reload nginx. To enable HTTPS, follow
# the Let's Encrypt section of the sac user guide.Document root and web content volume
Your web content lives on a dedicated, independently resizable 20 GiB EBS volume mounted at /var/www:
df -h /var/wwwFilesystem Size Used Avail Use% Mounted on /dev/nvme1n1 20G 32K 19G 1% /var/wwwThe document root is /var/www/html. Replace the default landing page, or deploy your site files there:
sudo cp -r /path/to/your-site/* /var/www/html/
sudo nginx -t && sudo systemctl reload nginxTo grow the volume, resize it in the AWS Console, then run:
sudo resize2fs /dev/nvme1n1 df -h /var/wwwNGINX configuration layout
/etc/nginx/ ├── nginx.conf
# main config (includes conf.d/*.conf and sites-enabled/*.conf) ├── conf.d/ │ ├── default.conf
# default server block on port 80 │ ├── sac-status.conf
# placeholder (stub_status is in default.conf) │ └── sample.conf.disabled
# reverse-proxy starter (rename to enable) └── sites-available/
# optional Debian-style sites sites-enabled/
# symlink your sites hereTo view the effective running configuration, run:
sudo nginx -T > /tmp/nginx-dump.txt 2>/dev/null; grep -E "root|index |server_name|listen 80|location" /tmp/nginx-dump.txtlisten 80 default_server; server_name _; root /var/www/html; index index.html index.htm; location / { location = /nginx_status {Monitor with stub_status
The stub_status endpoint is enabled at /nginx_status and is accessible from the instance itself:
curl -s http://127.0.0.1/nginx_statusActive connections: 1 server accepts handled requests 2 2 2 Reading: 0 Writing: 1 Waiting: 0To expose it to a trusted monitoring server, add an allow directive inside the /nginx_status location block in /etc/nginx/conf.d/default.conf, then reload:
sudo nginx -t && sudo systemctl reload nginxEnable the reverse-proxy starter
A documented reverse-proxy starter ships disabled at /etc/nginx/conf.d/sample.conf.disabled. To activate it, run:
sudo cp /etc/nginx/conf.d/sample.conf.disabled /etc/nginx/conf.d/sample.conf
sudo nano /etc/nginx/conf.d/sample.conf
# edit the upstream address
sudo nginx -t sudo systemctl reload nginxThe starter proxies requests to a backend, for example a Node.js app on port 3000. Edit the proxy_pass line to point to your backend.
Enable HTTPS with Let's Encrypt
- Point your domain's A record to the instance's public IP address.
- Install Certbot:
bash sudo apt-get install -y certbot python3-certbot-nginx
- Obtain and install a certificate. Replace
your-domain.comwith your domain:
bash sudo certbot --nginx -d your-domain.com -d www.your-domain.com
- Certbot edits your NGINX configuration and reloads the server automatically. Test auto-renewal:
bash sudo certbot renew --dry-run
Reloading vs restarting nginx
- Reload (zero downtime, preferred for configuration changes):
bash sudo nginx -t && sudo systemctl reload nginx
- Restart (needed after package upgrades):
bash sudo systemctl restart nginx
Support
SecureAnyCloud provides 24/7 technical support. Email sales@secureanycloud.com or use the AWS Marketplace support channel.
Need Help?
Our support team is available 24/7.
sales@secureanycloud.com