𝗨𝘀𝗶𝗻𝗴 𝗔𝗽𝗮𝗰𝗵𝗲 𝗮𝗻𝗱 𝗡𝗴𝗶𝗻𝘅 𝗣𝗿𝗼𝘅𝘆 𝗠𝗮𝗻𝗮𝗴𝗲𝗿 𝗳𝗼𝗿 𝗗𝗼𝗺𝗮𝗶𝗻 𝗔𝗰𝗰𝗲𝘀𝘀
You often run multiple services on a VPS. You want to use domain names instead of IP addresses and ports. This guide shows you how to use Apache to point a domain to Nginx Proxy Manager (NPM).
Step 1: Setup your DNS
You must point your subdomain to your VPS IP address.
- Go to your DNS provider.
- Create an A record.
- Set the host to your subdomain.
- Point it to your VPS IP.
Step 2: Configure Apache as a Reverse Proxy
Apache can take traffic from your domain and send it to your Docker container.
Create a new configuration file: sudo nano /etc/apache2/sites-available/ngx.iquipedigital.cloud.conf
Add this block to the file:
<VirtualHost *:80> ServerName ngx.iquipedigital.cloud ProxyPreserveHost On ProxyPass / http://127.0.0.1:8081/ ProxyPassReverse / http://127.0.0.1:8081/ ErrorLog ${APACHE_LOG_DIR}/ngx_error.log CustomLog ${APACHE_LOG_DIR}/ngx_access.log combined
Enable the proxy modules: sudo a2enmod proxy sudo a2enmod proxy_http
Enable your site and reload Apache: sudo a2ensite ngx.iquipedigital.cloud.conf sudo apachectl configtest sudo systemctl reload apache2
Step 3: Add SSL Security
Use Certbot to get an SSL certificate via Let’s Encrypt. sudo certbot --apache -d ngx.iquipedigital.cloud
Two ways to manage your services:
Use Apache as the front layer. Apache handles the domain and sends traffic to NPM. This works well if Apache is already running your main sites.
Use NPM as the front layer. Stop Apache from using ports 80 and 443. Let NPM listen on those ports directly. This lets you manage all subdomains through the NPM dashboard.
Choose the method that fits your workflow.
Source: https://dev.to/wildshark/using-apache-and-nginx-proxy-manager-together-for-domain-based-access-e63