Nginx with alias path

Hello, I know you officially don’t support nginx. I would be happy to solve this:
I want to have multiple services runnin on my Pi. For every service I want to reach via TLS from outside I have a subpath. For pihole I looked for “my.domain/pihole”, admininterface on my.domain/pihole/admin ecetera pp.
For that I copied the sample configuration from https://docs.pi-hole.net/guides/nginx-configuration/
I added a location “^~ /pihole” (Line 5 below). After that nginx wasn’t happy that location “XYZ” is outside location “/pihole” so I changed all encapsulated locations to prefix “/pihole”. Now nginx does not recognize the php-files (Line 18). It sends me an octet-stream with the index php-file. What did I do wrong?

server {
        listen 80 default_server;
        listen [::]:80 default_server;

                location ^~ /pihole {


                        alias  /var/www/html;
                        autoindex off;

                        index pihole/index.php index.php index.html index.htm;

                        location ^~ /pihole/ {
                                        expires max;
                                        try_files $uri $uri/ =404;
                        }

                        location ~ \.php$ {
                                        include snippets/fastcgi-php.conf;
                                        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                                        fastcgi_param FQDN true;
                                        auth_basic "Restricted"; #For Basic Auth
                                        auth_basic_user_file /etc/nginx/.htpasswd;  #For Basic Auth
                        }

                        location /pihole/*.js {
                                        index pihole/index.js;
                                        auth_basic "Restricted"; #For Basic Auth
                                        auth_basic_user_file /etc/nginx/.htpasswd;  #For Basic Auth
                        }

                        location /pihole/admin {
                                        root /var/www/html;
                                        index index.php index.html index.htm;
                                        auth_basic "Restricted"; #For Basic Auth
                                        auth_basic_user_file /etc/nginx/.htpasswd;  #For Basic Auth
                        }

                        location ~ /\.ht {
                                        deny all;
                        }
        }
}


Okay, I set a reverse proxy with lighttpd. But it consumes more memory…

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.