Reverse Proxy configuration using Nginx

Introduction

This guide explains how to configure NGINX as a reverse proxy for Defguard's components (Core and Proxy). The reverse proxy acts as an intermediary between users and Defguard services, handling HTTPS requests, routing internal gRPC communication, and ensuring encrypted connections between all components.

To provide HTTPS encryption, this guide also uses Certbot, a free, open-source tool from the Let’s Encrypt project. Certbot automatically issues and renews SSL/TLS certificates, allowing you to secure your Defguard domains without manual certificate management.

We assume in this guide that you run your Core and Proxy services on separate servers, and you run Certbot and Nginx on each one of them.

Installing Nginx and Certbot

Run the followign command to install Nginx and Certbot.

apt install nginx certbot

Disable the default Nginx configuration to avoid conflicts:

unlink /etc/nginx/sites-enabled/default

Obtaining SSL certificates

Use Certbot to generate SSL certificates.

For each service (Core, Proxy), run the following command on the server that your domain’s DNS records resolve to. Ensure that inbound traffic on port 80 is allowed by the firewall and that no other process is using this port.

Certbot verifies domain ownership using the HTTP-01 challenge, where it temporarily serves a validation file over port 80 for the exact domain you are requesting a certificate for.

If the request fails with a timeout or connection error, Let’s Encrypt could not reach this temporary server. This usually means the DNS record for that domain does not point to the correct public IP of the machine running Certbot, port 80 is blocked (firewall or Security Group), an IPv6 (AAAA) record is published but not supported on the server, or another service is already using port 80.

Ensure the domain’s DNS resolves to this server’s public IP, inbound port 80 is open, and no other service is binding the port before trying again.

Obtaining SSL certificate for Core service

Use the following command to generate certificate with Certbot. Replace the example domain for the Core service (my-server.defguard.net) with your own.

Certbot will generate certificate in fullchain.pem and privkey.pem in the following path:

Obtaining SSL certificate for Proxy service

Use the following command to generate certificate with Certbot. Replace the example domain for the Proxy service (enroll.defguard.net) with your own.

Certbot will generate certificate in fullchain.pem and privkey.pem in the following path:

Configuring and starting Nginx

Configuring and starting Nginx for Core service

Create a new configuration file for the Core service:

/etc/nginx/sites-available/my-server.defguard.net.conf

Enable the configuration and start Nginx:

To verify, run:

If you use this simple setup and run all services on one server, you can use NGINX access restrictions for securing core and allowing to access the my-server.defguard.net only to selected networks - blocking the direct access from the Internet.

Configuring and starting Nginx for Proxy service

The Proxy service exposes APIs for enrollment, remote onboarding, and desktop client configuration. Create its NGINX configuration file:

/etc/nginx/sites-available/enroll.defguard.net.conf

Enable and restart NGINX:

Security Recommendations

  • Only expose HTTPS ports (443) for web access.

  • Do not expose internal gRPC ports (444, 50051, 50055) directly to the Internet.

Summary

After completing the configuration:

  • Defguard Core is available at https://my-server.defguard.net

  • Enrollment and onboarding services are available at https://enroll.defguard.net

  • Both services are secured with SSL and reverse-proxied through NGINX.

Last updated

Was this helpful?