PiPass / blockpage

A temporary unblock solution and blockpage for your Pi-Hole system
BSD 3-Clause "New" or "Revised" License
196 stars 14 forks source link

Newb Help #40

Closed swvalenti194 closed 5 years ago

swvalenti194 commented 5 years ago

I have pihole installed and would like to implement your project however I am not advanced as you are. I noticed that you said the install script is mostly automated. Can you help me on how to install this mostly automated script as the wiki doesn't seem to explain that for me. Do I just run a simple git script and it guides me through the setup and if so what is script? What things do I need to do that doesn't mostly automate if so?

From Reddit:

_"I am really happy for the overwhelming support of my project! The issues/feature requests are getting hard to keep track of, so please create an issue on GitHub, I will no longer be replying to all comments on this post.

v1.3 is out! It includes an automated install script. Mostly automated..."_

Thanks, Scott

roenw commented 5 years ago

If you use lighttpd as your web server, which you most likely do, the script is completely automated.

Execute the following command exactly as it appears below: cd ~/ && wget -O setup.php https://apps.roen.us/pipass/setup && sudo php setup.php

swvalenti194 commented 5 years ago

Ok cool, but now what?

[ / ] DR check... Please enter your web document root. (e.g. /var/www/html)

roenw commented 5 years ago

To determine your web document root, can you run cat /etc/lighttpd/lighttpd.conf? It's likely /var/www/

swvalenti194 commented 5 years ago

y
[ + ] DR check succeeded, now installing PiPass... 
[ / ] Getting current php user...
[ + ] Current php user is pi.
[ / ] Building /etc/sudoers line to add...
[ / ] Checking if /etc/sudoers is already set up...
[ / ] /etc/sudoers is already set up... not performing action.
[ / ] Now making sure that your document root folder is clear...
[ + ] In document root... downloading files.
fatal: remote origin already exists.
fatal: Not a git repository (or any of the parent directories): .git
PHP Fatal error:  Uncaught Error: Call to undefined function curl_init() in /home/pi/setup.php:98
Stack trace:
#0 /home/pi/setup.php(108): get_data('https://apps.ro...')
#1 /home/pi/setup.php(48): install()
#2 /home/pi/setup.php(24): preInstall()
#3 {main}
  thrown in /home/pi/setup.php on line 98
``
roenw commented 5 years ago

php7.0-curl is a prerequisite. To install it, use sudo apt update && sudo apt install php7.0-curl

swvalenti194 commented 5 years ago

Ok cool almost there now what?

[ + ] Installation complete. Please set your webserver to redirect all 404 pages to the homepage (web root). This function is not automated yet. [ + ] NOTE: Make sure you fill out config.php or you will get stuck in a redirect loop!

roenw commented 5 years ago

Can you run cat /etc/lighttpd/lighttpd.conf? Also, determine the local/private IP address of your Raspberry Pi, e.g. 192.168.x.x

swvalenti194 commented 5 years ago

``# Pi-hole: A black hole for Internet advertisements

(c) 2017 Pi-hole, LLC (https://pi-hole.net)

Network-wide ad blocking via your own hardware.

#

Lighttpd config for Pi-hole

#

This file is copyright under the latest version of the EUPL.

Please see LICENSE file for your rights under this license.

###############################################################################

FILE AUTOMATICALLY OVERWRITTEN BY PI-HOLE INSTALL/UPDATE PROCEDURE.

ANY CHANGES MADE TO THIS FILE AFTER INSTALL WILL BE LOST ON THE NEXT UPDATE

CHANGES SHOULD BE MADE IN A SEPARATE CONFIG FILE:

/etc/lighttpd/external.conf

###############################################################################

server.modules = ( "mod_access", "mod_accesslog", "mod_auth", "mod_expire", "mod_compress", "mod_redirect", "mod_setenv", "mod_rewrite" )

server.document-root = "/var/www/html" server.error-handler-404 = "index.php" server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) server.errorlog = "/var/log/lighttpd/error.log" server.pid-file = "/var/run/lighttpd.pid" server.username = "www-data" server.groupname = "www-data" server.port = 80 accesslog.filename = "/var/log/lighttpd/access.log" accesslog.format = "%{%s}t|%V|%r|%s|%b"

index-file.names = ( "index.php", "index.html", "index.lighttpd.html" ) url.access-deny = ( "~", ".inc", ".md", ".yml", ".ini" ) static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

compress.cache-dir = "/var/cache/lighttpd/compress/" compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" )

default listening port for IPv6 falls back to the IPv4 port

include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port include_shell "/usr/share/lighttpd/create-mime.assign.pl"

Prevent Lighttpd from enabling Let's Encrypt SSL for every blocked domain

include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

include_shell "find /etc/lighttpd/conf-enabled -name '*.conf' -a ! -name 'letsencrypt.conf' -printf 'include \"%p\"\n' 2>/dev/null"

If the URL starts with /admin, it is the Web interface

$HTTP["url"] =~ "^/admin/" {

Create a response header for debugging using curl -I

setenv.add-response-header = (
    "X-Pi-hole" => "The Pi-hole Web interface is working!",
    "X-Frame-Options" => "DENY"
)

$HTTP["url"] =~ ".ttf$" {
    # Allow Block Page access to local fonts
    setenv.add-response-header = ( "Access-Control-Allow-Origin" => "*" )
}

}

Block . files from being served, such as .git, .github, .gitignore

$HTTP["url"] =~ "^/admin/.(.*)" { url.access-deny = ("") }

Add user chosen options held in external file

This uses include_shell instead of an include wildcard for compatibility

include_shell "cat external.conf 2>/dev/null" ``

and pihole is 192.168.0.22

roenw commented 5 years ago

Can you rerun the setup script, but put /var/www/html in there instead? Also, cd /var/www/ && sudo rm -r index.php config.php blockpage README.md .git setup to clean up the old files.

After you do that, use your favorite text editor to edit /var/www/html/config.php and change the blockpage_url line. Put 192.168.0.22/blockpage between the quotes on that line.

swvalenti194 commented 5 years ago

``<?php /* For your PiPass system to function properly, it's reccomended that you modify all of these variables to appropriate values. An explanation of each variable is listed as a comment below the variable.

NOTE: All PiPass files are dependent upon this one configuration file. Your changes will be widespread! */

$conf['show_tech_info'] = true; // Should usually be set to true, unless you have specific reason to disable // it. Determines whether the program should show technical info.

$conf['blockpage_url'] = "192.168.0.22/blockpage"; // The URL (not directory) of your blockpage. Setting this incorrectly can // lead to SSL certificate SAN errors, which prompt the user that the // connection is "not secure." It's highly reccomended that you change this. // Example: "https://example.com/blockpage/" ``

Added this yet when I got to an ad page I get this...

pipass

swvalenti194 commented 5 years ago

Feel like I'm there minus a stupid step...

swvalenti194 commented 5 years ago

I can see blockpage if go to http://192.168.0.22/blockpage/ but now when on a blocked site

plankobostjan commented 5 years ago

@swvalenti194 It looks like you have the wrong blocking mode set for the Pi-hole. It should be set to IP or IP-NODATA-AAAA.

To set the right mode add BLOCKINGMODE=IP-NODATA-AAAA to /etc/pihole/pihole-FTL.conf

Then restart Pi-hole FTLDNS: sudo killall -SIGHUP pihole-FTL

Now try going to a blocked page and PiPass blockpage should show up.

swvalenti194 commented 5 years ago

I did that but still no luck when...can you suggest a link to use to test to see if I get the blockpage?

plankobostjan commented 5 years ago

@swvalenti194 Any page on the blacklist should work (or not if it has HSTS header)...

You can try with adding the bettermotherfuckingwebsite.com (since it doesn't have HSTS) to the Pi-hole blacklist and then try visiting it.

swvalenti194 commented 5 years ago

I added it to pihole but it still doesn't block the site...

swvalenti194 commented 5 years ago

http://bettermotherfuckingwebsite.com/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/192.168.0.22/blockpage/?url=bettermotherfuckingwebsite.com

Then I get a 431 -

swvalenti194 commented 5 years ago

I got it all....thanks for time and patience!