I have installed the LEMP stack and then Pihole using dietpi-software. I would like to change the default port for Pihole to something like http://ip:8080/admin
instead of http://ip/admin
.
I have tried adding the ‘listen’ directive in the /etc/nginx/sites-dietpi/dietpi-pihole.conf
file, but I couldn’t restart nginx, and the nginx test fails.
# Based on: https://github.com/pi-hole/pi-hole/blob/c1335c68524e83abe5d13015944679198bc92363/advanced/pihole-admin.conf
# Admin panel
location ~ ^(?:/html|)/admin(?:$|/) {
listen: 8080;
# 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/\. { return 404; }
# Add response headers
add_header X-Pi-hole "The Pi-hole Web interface is working!";
add_header X-Content-Type-Options "nosniff";
set $frame_options "deny";
add_header X-Frame-Options "$frame_options";
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag "noindex, nofollow";
add_header X-Permitted-Cross-Domain-Policies "none";
add_header Referrer-Policy "same-origin";
add_header Content-Security-Policy "default-src 'self' 'unsafe-inline'";