Skip to content

nginx config in documentatation does not work well #962

Open
@AlfredoCubitos

Description

@AlfredoCubitos

Versions

Pi-hole version is v5.17.2 (Latest: v5.17.2)
web version is v5.21 (Latest: v5.21)
FTL version is v5.23 (Latest: v5.23)

Platform

armbian
banana-Pi

The nginx config from NGINX-Doku does not work well.
E.g. no values are shown in the Dashboard.

So I'm using the following config which is based on Diet-Pi config Diet-Pi config

This works well for me :-)

    listen 80 default_server;

    root /var/www/html;
    server_name _;

    index index.php index.html;

    location / {
        expires max;
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
	fastcgi_split_path_info ^(.+?\.php)(/.*)$;
	fastcgi_param HTTP_PROXY "";
        include fastcgi_params;
	fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
	fastcgi_param FQDN true;
        fastcgi_pass unix:/run/php/php8.2-fpm.sock;
	fastcgi_index index.php;
    }
   
   # Based on: https://github.com/pi-hole/pi-hole/blob/master/advanced/lighttpd.conf.debian

# Allow teleporter and API QR code iframes on settings page
location ~ ^(?:/html|)/admin/scripts/pi-hole/php/(?:teleporter|api_token)\.php$ {
	# PHP handler block
	fastcgi_pass unix:/run/php/php8.2-fpm.sock;
	include snippets/fastcgi-php.conf;

	if ($http_referer !~ /admin/settings\.php) {
		add_header X-Frame-Options "DENY";
	}
	if ($http_referer ~ /admin/settings\.php) {
		add_header X-Frame-Options "SAMEORIGIN";
	}
}


# Admin panel
location ~ ^(?:/html|)/admin(?:$|/) {
	# Block public access to admin page, if enabled
	# - To enable: cd /etc/nginx/sites-dietpi; mv dietpi-pihole-block_public_admin.off dietpi-pihole-block_public_admin.on
	# - To disable: cd /etc/nginx/sites-dietpi; mv dietpi-pihole-block_public_admin.on dietpi-pihole-block_public_admin.off
	include sites-dietpi/dietpi-pihole-block_public_admin.*on;

	# Block . files from being served, such as .git, .github, .gitignore
	location ~ ^(?:/html|)/admin/\. {
		deny all;
	}

	# Create response header for Pi-hole debugger
	add_header X-Pi-hole "The Pi-hole Web interface is working!";
	add_header X-Frame-Options "DENY";

	# Standard PHP handler block
	try_files $uri $uri/ =404;
	location ~ ^(?:/html|)/admin/.+\.php(?:$|/) {
		fastcgi_pass unix:/run/php/php8.2-fpm.sock;
		include snippets/fastcgi-php.conf;
	}
}

# 404 page
location ~ ^(?:/html|)/pihole(?:$|/) {
	# Block public access
	allow 127.0.0.0/8;
	allow 192.168.0.0/16;
	allow 10.0.0.0/8;
	allow 172.16.0.0/12;
	allow ::1/128;
	allow fe80::/10;
	allow fc00::/7;
	deny all;

	# Standard PHP handler block
	try_files $uri $uri/ =404;
	location ~ ^(?:/html|)/pihole/.+\.php(?:$|/) {
		fastcgi_pass unix:/run/php/php8.2-fpm.sock;
		include snippets/fastcgi-php.conf;
	}
}

}


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions