mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-28 00:53:19 +00:00
Fixed Pi-Hole header for nginx, and default page display
This commit is contained in:
parent
dda66a70bd
commit
fa21951ab7
3 changed files with 49 additions and 13 deletions
|
@ -2,11 +2,11 @@ server {
|
||||||
listen 80;
|
listen 80;
|
||||||
listen [::]:80;
|
listen [::]:80;
|
||||||
root /var/www/html;
|
root /var/www/html;
|
||||||
|
index index.php index.html index.nginx-debian.html;
|
||||||
|
|
||||||
error_page 404 /pihole/index.html;
|
error_page 404 /pihole/index.html;
|
||||||
|
|
||||||
location ~ ^/admin/ {
|
location ~ ^/admin/ {
|
||||||
index index.php;
|
|
||||||
add_header X-Pi-hole "The Pi-hole Web interface is working!";
|
add_header X-Pi-hole "The Pi-hole Web interface is working!";
|
||||||
|
|
||||||
location ~ .php$ {
|
location ~ .php$ {
|
||||||
|
@ -18,6 +18,6 @@ server {
|
||||||
}
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
add_header X-Pi-hole "A black hole for Internet advertisements.";
|
add_header X-Pi-hole "A black hole for Internet advertisements." always;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -317,6 +317,38 @@ installConfigs(){
|
||||||
$SUDO echo " done."
|
$SUDO echo " done."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
installNginx(){
|
||||||
|
currentNginxIsUpToDate=$(dpkg --compare-versions $(dpkg -l | grep nginx | grep 'ii' | head -n 1 | awk '{print $3}') ge-nl 1.7.5 2> /dev/null && echo '0' || echo '1')
|
||||||
|
minimumNginxVersionAvailable=$(dpkg --compare-versions $(apt-cache madison nginx | awk '{print $3}' | sort -V | tail -n 1) ge-nl 1.7.5 && echo '0' || echo '1')
|
||||||
|
installNginxFromTesting=1
|
||||||
|
|
||||||
|
echo -n "::: Checking for nginx..."
|
||||||
|
if [ $(dpkg-query -W -f='${Status}' nginx 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
|
||||||
|
echo -n " Not found! Installing...."
|
||||||
|
if [ $minimumNginxVersionAvailable -eq 0 ]; then
|
||||||
|
$SUDO apt-get -y -qq install nginx > /dev/null & spinner $!
|
||||||
|
echo " done!"
|
||||||
|
else
|
||||||
|
installNginxFromTesting=0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo -n " already installed"
|
||||||
|
if [ $currentNginxIsUpToDate -eq 0 ]; then
|
||||||
|
echo "!"
|
||||||
|
else
|
||||||
|
echo -n " (but version is too old)! Installing..."
|
||||||
|
installNginxFromTesting=0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $installNginxFromTesting -eq 0 ]; then
|
||||||
|
$SUDO cat /etc/apt/sources.list | grep deb | grep main | grep -vE '^\s*#' | sed -E 's@(stretch|wheezy|jessie)(-staging)?@testing@g' >> /etc/apt/sources.list
|
||||||
|
$SUDO apt-get -y -qq update & spinner $!
|
||||||
|
$SUDO apt-get -y -qq -t testing install nginx > /dev/null & spinner $!
|
||||||
|
echo " done!"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
stopServices(){
|
stopServices(){
|
||||||
$SUDO echo ":::"
|
$SUDO echo ":::"
|
||||||
$SUDO echo -n "::: Stopping services..."
|
$SUDO echo -n "::: Stopping services..."
|
||||||
|
@ -393,14 +425,18 @@ checkForDependencies(){
|
||||||
|
|
||||||
for i in "${dependencies[@]}"
|
for i in "${dependencies[@]}"
|
||||||
do
|
do
|
||||||
:
|
# nginx has a little more sophisticated installation script, so it needs a special treatment.
|
||||||
echo -n "::: Checking for $i..."
|
if [ $i == 'nginx' ]; then
|
||||||
if [ $(dpkg-query -W -f='${Status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
|
installNginx
|
||||||
echo -n " Not found! Installing...."
|
|
||||||
$SUDO apt-get -y -qq install $i > /dev/null & spinner $!
|
|
||||||
echo " done!"
|
|
||||||
else
|
else
|
||||||
echo " already installed!"
|
echo -n "::: Checking for $i..."
|
||||||
|
if [ $(dpkg-query -W -f='${Status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
|
||||||
|
echo -n " Not found! Installing...."
|
||||||
|
$SUDO apt-get -y -qq install $i > /dev/null & spinner $!
|
||||||
|
echo " done!"
|
||||||
|
else
|
||||||
|
echo " already installed!"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -478,10 +514,10 @@ installPiholeWeb(){
|
||||||
else
|
else
|
||||||
$SUDO mkdir /var/www/html/pihole
|
$SUDO mkdir /var/www/html/pihole
|
||||||
if [ $piholeWebserver == 'lighttpd' ]; then
|
if [ $piholeWebserver == 'lighttpd' ]; then
|
||||||
$SUDO mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig
|
$SUDO cp /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig
|
||||||
fi
|
fi
|
||||||
if [ $piholeWebserver == 'nginx' ]; then
|
if [ $piholeWebserver == 'nginx' ]; then
|
||||||
$SUDO mv /var/www/html/index.nginx-debian.html /var/www/html/index.nginx-debian.orig
|
$SUDO cp /var/www/html/index.nginx-debian.html /var/www/html/index.nginx-debian.orig
|
||||||
fi
|
fi
|
||||||
$SUDO cp /etc/.pihole/advanced/index.html /var/www/html/pihole/index.html
|
$SUDO cp /etc/.pihole/advanced/index.html /var/www/html/pihole/index.html
|
||||||
$SUDO echo " done!"
|
$SUDO echo " done!"
|
||||||
|
|
|
@ -2,11 +2,11 @@ server {
|
||||||
listen 80;
|
listen 80;
|
||||||
listen [::]:80;
|
listen [::]:80;
|
||||||
root /var/www/html;
|
root /var/www/html;
|
||||||
|
index index.php index.html index.nginx-debian.html;
|
||||||
|
|
||||||
error_page 404 /pihole/index.html;
|
error_page 404 /pihole/index.html;
|
||||||
|
|
||||||
location ~ ^/admin/ {
|
location ~ ^/admin/ {
|
||||||
index index.php;
|
|
||||||
add_header X-Pi-hole "The Pi-hole Web interface is working!";
|
add_header X-Pi-hole "The Pi-hole Web interface is working!";
|
||||||
|
|
||||||
location ~ .php$ {
|
location ~ .php$ {
|
||||||
|
@ -18,7 +18,7 @@ server {
|
||||||
}
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
add_header X-Pi-hole "A black hole for Internet advertisements.";
|
add_header X-Pi-hole "A black hole for Internet advertisements." always;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue