Skip to content

Instantly share code, notes, and snippets.

@terrywang
Created July 28, 2022 21:48
Show Gist options
  • Save terrywang/7cc8f1b5bbe9a5a28bb5b18b706ae98a to your computer and use it in GitHub Desktop.
Save terrywang/7cc8f1b5bbe9a5a28bb5b18b706ae98a to your computer and use it in GitHub Desktop.
Nginx Configuration for Pi-hole
server {
listen 80 default_server;
# listen [::]:80 default_server;
root /var/www/html;
server_name _;
autoindex off;
index pihole/index.php index.php index.html index.htm;
error_page 404 pihole/index.php;
location / {
expires max;
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
fastcgi_param FQDN true;
auth_basic "Restricted"; # For Basic Auth
auth_basic_user_file /etc/nginx/.htpasswd; # For Basic Auth
}
location /*.js {
index pihole/index.js;
auth_basic "Restricted"; # For Basic Auth
auth_basic_user_file /etc/nginx/.htpasswd; # For Basic Auth
}
location /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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment