Implement blahdns verification service is one of my personal projects try to bring Ads block by default to my personal use. Since 2016, I started to make it public and implement tons of block list such as malware, scam, phishing, fake news, etc.
In 2018 Jun, after implement unencrypted DNS service, I think is time to move forward to an encrypted DNS world. So I learned how to do DNS over HTTPS, TLS and implement TLS1.3 to ensure the security and makes ISP or GOV harder to sniff the DNS traffic.


Implement dns verficication service into my site

# Select a div#status and try to fetch url, if url found will return status 0 or 403, then success.

const text = document.querySelector("#status")
    const url = ''
    fetch(url, {
        credentials: 'same-origin',
        method: "HEAD",
        mode: "no-cors",
        cache: "no-cache",
        if (response.status == 0 || response.status == 403) {
            text.innerHTML = "You're <strong>using</strong> Blahdns"
        } else {
            text.innerHTML = "You're <strong> not </strong> usingBlahdns"
    .catch(error => console.log(error) );

From the very beginning, I tried to just deal with HTTP. It is easier to do a test, but I realize that Chrome 70 and Firefox 65 they already block CORS and HTTPS, so I try out myself by following steps.

  1. Add domain A record at domain provider
  2. Put a real IP into and get a Let’s Encrypt SSL cert
  3. Remove the A record, and add vhost in Nginx server to serve
  4. In my blahdns resolver, I manually insert A record in it. 
  5. Done !

I tried on HAproxy and some Javascript, here is some hints to achieve.

# HA Proxy
frontend www
  acl app_2 req.ssl_sni -i
  # http acl app_2 hdr_dom(host) -i
  use-server server2 if app_2
  ... OR ...
  default_backend no-match

backend no-match
  http-request deny deny_status 400

# Javascript
# Some sample show out I can use HEAD to check
$.ajax({url: "",
        type: "HEAD",
        statusCode: {
            200: function (response) {
            400: function (response) {
                alert('Not working!');
            0: function (response) {
                alert('Not working!');

# Mixed Content error?
## allow 
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
## block
<meta http-equiv="Content-Security-Policy" content="block-all-mixed-content">

# NGiNX disable HSTS
server {
        ssl on;
        add_header Strict-Transport-Security "max-age=0;";

2. (Nginx add CORS allow header)
3. (HAproxy add CORS allow header)
8. (CROSS-Proxy)

Featured Image by Ricardo Gomez Angel on Unsplash