I have 2gb and 2vCores CPU vps hosted with ip 146.59.147.12 and I have a domain satteen.com on cloudflare.
I have already installed niginx and did some configuration with it and I am already reversing port 9000... however I want to reverse two ports 9000 and 1337.
9000 to admin.satteen.com
1337 to cms.satteen.com
They are both admin dashboards. reverse them with high performance. and help me to configure the dns.
Assistant
To reverse proxy two different ports (9000 and 1337) to separate subdomains (admin.satteen.com and cms.satteen.com) using Nginx on your VPS, follow the steps below. This guide also includes DNS configuration on Cloudflare and performance optimization tips to ensure high performance.
[image: Cloudflare DNS Settings] open(Replace with actual image if needed)
Save the Records:
Click "Save" or "Add Record" after entering each subdomain.
Note: Allow some time for DNS propagation, although Cloudflare usually propagates instantly.
Nginx Configuration
1. Install Necessary Dependencies
Ensure that Nginx is installed. If not, install it using your package manager.
bash
sudo apt update
sudo apt install nginx
2. Obtain SSL Certificates
Although Cloudflare provides SSL termination, it's recommended to use "Full" or "Full (Strict)" SSL modes for better security. You can use Cloudflare Origin Certificates or Let's Encrypt for end-to-end encryption.
Use modern, secure ciphers and protocols (already partially included).
nginx
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256...'; # Use recommended cipher list
ssl_prefer_server_ciphers on;
Note: Always test changes to ensure they don't negatively impact functionality.
Firewall Configuration (Optional but Recommended)
Enhance your server's security by configuring a firewall to allow only necessary traffic.
Install UFW (Uncomplicated Firewall):
bash
sudo apt install ufw
Allow SSH:
bash
sudo ufw allow OpenSSH
Allow HTTP and HTTPS:
bash
sudo ufw allow 'Nginx Full'
Enable UFW:
bash
sudo ufw enable
Check UFW Status:
bash
sudo ufw status
Final Verification
Access the Subdomains:
Visit https://admin.satteen.com and https://cms.satteen.com in your browser.
Check SSL:
Ensure SSL certificates are correctly installed and active.
Verify Reverse Proxy:
Confirm that each subdomain correctly proxies to its respective internal port (9000 and 1337).
Check Nginx Logs for Errors:
bash
sudo tail -f /var/log/nginx/error.log
Monitor the logs while accessing the subdomains to catch any issues.
Additional Recommendations
Monitoring and Logging:
Implement monitoring tools like Prometheus, Grafana, or Netdata to keep an eye on server performance.
Use centralized logging solutions if needed.
Security Enhancements:
Implement fail2ban to prevent brute-force attacks.
Regularly update your server and software to patch vulnerabilities.
Scaling Considerations:
With 2GB RAM and 2 vCores, monitor resource usage to ensure the server handles the load efficiently.
Optimize the backend services running on ports 9000 and 1337 for better performance.
Backup Strategy:
Regularly back up your Nginx configuration and any important data related to your admin dashboards.
By following these steps, you will have successfully configured Nginx to reverse proxy two different ports to separate subdomains with optimized performance and secure DNS settings through Cloudflare.