DEV Community

Cover image for Using Apache and Nginx Proxy Manager Together for Domain-Based Access
iQuipe Digital
iQuipe Digital

Posted on

Using Apache and Nginx Proxy Manager Together for Domain-Based Access

Introduction

When running applications on a VPS, it’s common to have multiple services that need to be exposed under different domain names. In your case, Apache is already running on the server, while Nginx Proxy Manager (NPM) is deployed in a Docker container. The goal is to make NPM accessible via the subdomain ngx.iquipedigital.com instead of the raw IP and port (http://210.192.2.190:8081).

Your current browsing session shows active work on this setup, with tabs open for Nginx Proxy Manager, Docker installation guides, and your iQuipé Cloud dashboard. This reflects a typical workflow: researching, configuring, and testing in real time.


Step 1: DNS Configuration

The first step is to ensure that the domain points to your VPS:

  • Create an A record in your DNS provider (Hostman or wherever iquipe.cloud is managed).
  • Set the host to ngx.
  • Point it to your VPS IP: 210.192.2.190.

This ensures that requests to ngx.iquipedigital.com resolve to your server.


Step 2: Apache Reverse Proxy Setup

Since Apache is already running, you can configure it to forward traffic for ngx.iquipedigital.com to the Docker container running NPM.

  1. Create a new site configuration file:
   sudo nano /etc/apache2/sites-available/ngx.iquipedigital.com.conf
Enter fullscreen mode Exit fullscreen mode
  1. Add the following VirtualHost block:
   <VirtualHost *:80>
       ServerName ngx.iquipedigital.com

       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
   </VirtualHost>
Enter fullscreen mode Exit fullscreen mode
  1. Enable required modules:
   sudo a2enmod proxy
   sudo a2enmod proxy_http
Enter fullscreen mode Exit fullscreen mode
  1. Enable the site and reload Apache:
   sudo a2ensite ngx.iquipedigital.com.conf
   sudo apachectl configtest
   sudo systemctl reload apache2
Enter fullscreen mode Exit fullscreen mode

Step 3: SSL/TLS Security

To secure the domain with HTTPS:

sudo certbot --apache -d ngx.iquipedigital.com
Enter fullscreen mode Exit fullscreen mode

This will automatically configure SSL certificates via Let’s Encrypt.


Step 4: Testing

Once configured:

  • Visit http://ngx.iquipedigital.com in your browser.
  • You should see the Nginx Proxy Manager login page.
  • If SSL is enabled, test https://ngx.iquipedigital.com.

Alternative Approach: Let NPM Handle Ports Directly

If you prefer to manage all subdomains through Nginx Proxy Manager’s dashboard:

  • Stop Apache from binding to ports 80 and 443.
  • Configure Docker/NPM to listen directly on those ports.
  • Use NPM’s GUI to add proxy hosts for each subdomain (go.iquipedigital.com, school.iquipedigital.com, etc.).

This approach centralizes domain management in NPM and avoids Apache configs, but it requires that Apache not occupy the same ports.


Conclusion

By combining DNS records, Apache reverse proxy configuration, and SSL certificates, you can seamlessly expose Nginx Proxy Manager under a clean domain name. Your browsing context shows you’re already exploring Dockerization guides and NPM setup documentation, which aligns perfectly with this workflow. Whether you keep Apache as the front-facing proxy or hand over control to NPM entirely depends on how you want to manage multiple services on your VPS.

Top comments (0)