DNS over HTTPS Nginx reverse proxy with HTTP/3

515 Views Asked by At

I am trying to setup my own DoH server running on Bind with Nginx as a reverse proxy. While it seems to be working with Firefox it doesn't work on Android 13 using HTTP/2. I found that DoH has been dropped in favor of DoT in Android but later Google decided to add DoH support with HTTP/3. I have installed the latest Nginx from Nginx repo and configured vhost to use HTTP/3 but unfortunately this doesn't work at all throwing 502 even in FireFox.

upstream doh-servers {
        server 192.168.1.15:443;
}

server {
        listen 80;
        server_name domain;
        return 301 https://$server_name$request_uri;
       }

server {
        listen 443 quic reuseport;
        listen 443 ssl; 
#       http2 on;
        server_name domain;
        quic_retry on;
        ssl_early_data on;

        access_log /var/log/nginx/domain-access.log;
        error_log /var/log/nginx/domain-error.log;

        ssl_certificate /etc/letsencrypt/live/domain/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/domain/privkey.pem;
        ssl_trusted_certificate /etc/letsencrypt/live/domain/chain.pem;

        ssl_session_timeout 1d;
        ssl_session_cache shared:DoHSSL:10m;
        ssl_session_tickets off;
        ssl_dhparam /etc/nginx/dhparam.pem;

        ssl_protocols TLSv1.3;
        ssl_prefer_server_ciphers off;
  
        ssl_stapling on;
        ssl_stapling_verify on;

        add_header Strict-Transport-Security "max-age=63072000" always;

        location / {
                return 404;
        }

        location /dns-query {
                grpc_pass grpcs://doh-servers;
                grpc_socket_keepalive on;
                grpc_connect_timeout 10s;
                grpc_ssl_verify off;
                grpc_ssl_protocols TLSv1.3;
        }

}

I've tried with:

               proxy_set_header Upgrade $http_upgrade;
               proxy_set_header Connection "upgrade";
               proxy_set_header Host $host;
               proxy_pass http://doh-servers;
               proxy_set_header X-Real-IP $remote_addr;
               proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
               proxy_set_header X-Forwarded-Proto $scheme;
               proxy_set_header X-Forwarded-Host $host;
               proxy_set_header X-Forwarded-Port $server_port;
               proxy_http_version 1.1;

but with no luck.

Firstly: Is it possible at all to force clean Android 13 (Pixel) to use DoH or I am wasting time? Secondly: If the answer for my first question is true then, what I am missing here?

0

There are 0 best solutions below