Set up a DNS-over-HTTPS server

With a Debian server, Unbound, Nginx, and doh-proxy, you can set up your own DNS-over-HTTPS server.


In this guide, we’ll show you how to set up your own DoH (DNS‑over‑HTTPS) server and start sending encrypted DNS queries in less than half an hour using Glesys Cloud.

We’ll be using a Debian server with nginx, a DoH proxy, and Unbound, along with Let’s Encrypt and a domain name that you’ll need to provide.

Setting up the DNS-over-HTTPS server

Start by logging in to our control panel and provisioning a server running Debian 12 or later. After you have selected an IP address for your server, go to the DNS in Glesys Cloud and point doh.example.com (replace example.com with your own domain) to the IPv4 and IPv6 addresses assigned to your server.

Start by updating your server:

Commands
sudo apt update
sudo apt upgrade

Once that’s done, it’s time to begin the installation.

We start by installing unbound . Unbound is a recursive and caching name server. This is what will make the actual DNS look-ups.

Commands
sudo apt install unbound
sudo systemctl enable unbound
sudo systemctl start unbound

Then, download the latest version of doh-proxy for Debian amd64 from this site https://github.com/DNSCrypt/doh-server/releases.

Once downloaded, install it with (replace the version with the version you downloaded):

Command
sudo apt install ./doh-proxy_0.9.15-1_amd64.deb

Next, you need to create a user to run doh-proxy (to avoid having it run as root):

Command
sudo adduser --home /var/lib/proxy --comment "Homer says DOH" --shell /sbin/nologin --system --group doh-proxy

To make doh-proxy start automatically when the server boots, create a systemd service for it in /etc/systemd/system/doh-proxy.service.

To make the system recognize this new service, reload the systemd daemon:

Next, install Nginx and Certbot for Nginx:

Now it's time to issue a Let's Encrypt certificate for the Nginx server using Certbot (replace example.com with your real domain):

If you try accessing https://doh.example.com now, you should see Nginx default welcome page.

Now it's time to configure HTTP/2 and Nginx with doh-proxy. Edit the file /etc/nginx/sites-available/default. Find the following two lines in that file:

Add http2 to those line so that they instead look like this:

Then find the line that reads:

Right below that line, add the following to tell Nginx that we only accept HEAD, GET, and POST requests:

The next step is to configure the backend. Find the lines that read something like the example below. Remember that this should be inside the server block for HTTPS.

Replace that entire block with this code:

Next, at the very end of the file, after the final bracket, add the following:

That's it. Now, save the file, exit the editor, and restart Nginx:

Next, start and enable the doh-proxy service:

Testing the DNS-over-HTTPS server

Congratulations! Everything is now set up, and you can try out your DoH server. To test it, you can use cURL, preferably from your own computer. Remember to use your own domain, not example.com.

If it worked, you should get a reply like this:

Now, you can add your DNS-over-HTTPS server to Firefox:

Last updated

Was this helpful?