Nginx SSL/TLS Reverse Proxy Setup Help

I am trying setup pihole to be able to access via https, but getting 400 error. Currently, I am able to access with this lines

http://local-ip-address/admin/
http://pi.hole/admin/

This is the error when I try to access via https://pihole.domain.com

400
THE REQUESTED URL COULD NOT BE RETRIEVED: /ADMIN/

This is my nginx confi file.

            ## Pihole Server
            ## SSL Redirects non www
    server {
            listen 80;
            server_name www.pihole.domain.com pihole.domain.com;
            return 301 https://pihole.domain.com$request_uri;
            }

    server {
            listen 443 ssl http2;
            server_name www.pihole.domain.com;
            include /etc/ssl/domain.com.conf;
            return 301 https://pihole.domain.com$request_uri;
            }

            ## End SSL Redirects non www

    server {
            listen 443 ssl;
            index index.html index.htm index.php;
            server_name pihole.domain.com;
            include /etc/ssl/domain.com.conf;

            ## Begin - Server Info

              location / {
                proxy_pass_header Authorization;
                proxy_pass http://192.168.1.10/admin/;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_http_version 1.1;
                proxy_set_header Connection "";
                proxy_buffering off;
                client_max_body_size 0;
                proxy_read_timeout 36000s;
                proxy_redirect off;
              }
            }
            ## End Pihole Media Server

So, first, why do you have a Second redirect where you are excluding the http2 part? There’s not really much of a need to add that extra step in there… Plus, you can use multiple server names on one line:

server_name pihole.xx.com www.pihole.xx.com

And, next, you do need to have two location blocks: one for the root / and one for the /admin as well, as thats how the main web interface is setup, anyways.

I’ve included my personal nginx config file for my pihole interface. NOW, caveat that I haven’t worked on just yet: when you try to access the root url, pihole.jpcdi.com , it doesn’t load up correctly, but the /admin page DOES load up correctly.

And the include directives are my regular proxy parameters that I use on almost ALL of my proxied locations, making my files much easier to read and easier to build new connections.

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    # server name
    server_name pihole.jpcdi.com;

    # proxy cache activation for all locations
    proxy_cache one;

    # Logs
    error_log /var/log/nginx/pihole.jpcdi_error.log error;
    access_log /var/log/nginx/pihole.jpcdi_access.log main;

    root /var/www/html;
    index pihole/index.php index.php index.html index.htm;

    location / {
        proxy_pass http://##my_internal_ip##;
        include /etc/nginx/snippets/proxy_params.conf;
    }

    location /admin {
        proxy_pass http://10.0.100.37;
        include /etc/nginx/snippets/proxy_params.conf;
    }

}