mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-24 07:03:43 +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;
|
||||
root /var/www/html;
|
||||
index index.php index.html index.nginx-debian.html;
|
||||
|
||||
error_page 404 /pihole/index.html;
|
||||
|
||||
location ~ ^/admin/ {
|
||||
index index.php;
|
||||
add_header X-Pi-hole "The Pi-hole Web interface is working!";
|
||||
|
||||
location ~ .php$ {
|
||||
|
@ -18,6 +18,6 @@ server {
|
|||
}
|
||||
|
||||
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."
|
||||
}
|
||||
|
||||
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(){
|
||||
$SUDO echo ":::"
|
||||
$SUDO echo -n "::: Stopping services..."
|
||||
|
@ -393,14 +425,18 @@ checkForDependencies(){
|
|||
|
||||
for i in "${dependencies[@]}"
|
||||
do
|
||||
:
|
||||
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!"
|
||||
# nginx has a little more sophisticated installation script, so it needs a special treatment.
|
||||
if [ $i == 'nginx' ]; then
|
||||
installNginx
|
||||
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
|
||||
done
|
||||
}
|
||||
|
@ -478,10 +514,10 @@ installPiholeWeb(){
|
|||
else
|
||||
$SUDO mkdir /var/www/html/pihole
|
||||
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
|
||||
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
|
||||
$SUDO cp /etc/.pihole/advanced/index.html /var/www/html/pihole/index.html
|
||||
$SUDO echo " done!"
|
||||
|
|
|
@ -2,11 +2,11 @@ server {
|
|||
listen 80;
|
||||
listen [::]:80;
|
||||
root /var/www/html;
|
||||
index index.php index.html index.nginx-debian.html;
|
||||
|
||||
error_page 404 /pihole/index.html;
|
||||
|
||||
location ~ ^/admin/ {
|
||||
index index.php;
|
||||
add_header X-Pi-hole "The Pi-hole Web interface is working!";
|
||||
|
||||
location ~ .php$ {
|
||||
|
@ -18,7 +18,7 @@ server {
|
|||
}
|
||||
|
||||
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