Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Instruction Guide moOde and Pi-Hole on Nginx
#15
(11-30-2019, 04:37 PM)TookaFace Wrote: Just a little how-to for running Pi-Hole with moOde on Nginx web server.

Works for moOde 6.4 and higher

    - Install Pi-Hole:
Code:
curl -sSL https://install.pi-hole.net | bash

     - When prompted, answer Off to that question:
Code:
Do you wish to install the web server (lighttpd) and required PHP modules?
Off

    - Once the installation is complete, open this file:
Code:
sudo nano /etc/nginx/sites-available/default

    - Delete all contents and copy that instead:
Code:
server {
   listen 8080 default_server;
   listen [::]:8080 default_server;

   root /var/www/html;
   server_name _;
   autoindex off;
   error_page 404 /pihole/index.php;

   index pihole/index.php index.php index.html index.htm;

   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/php7.3-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;
   }
}

    - Set rights for Pi-Hole folder and add pihole user to www-data group:
Code:
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html
sudo usermod -aG pihole www-data

    - Open this file:
Code:
sudo nano -l /etc/nginx/nginx.conf

    - And uncomment line 64 (include /etc/nginx/sites-enabled/*):
Code:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    client_max_body_size 8M;

    ##
    # SSL Settings
    ##

    #ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    #ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    #include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

    ##
    # moOde UI server
    ##

    server {
        listen 80;

        location / {
            root /var/www;
            index index.html index.php;
            try_files $uri $uri/ /coverart.php;
        }

        location /imagesw/ {
            root /var/local/www;
        }

        # php-fpm
        location ~ \.php$ {
            root /var/www;
            fastcgi_pass unix:/run/php/php7.3-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $request_filename;
            include fastcgi_params;
        }
    }
}

    - Restart PHP and Nginx:
Code:
sudo systemctl restart php7.3-fpm.service
sudo systemctl restart nginx

    - At this point, you should can access to Pi-Hole:
Code:
http://pi.hole:8080/admin/

    - To finish, update moOde database:
Code:
sudo sqlite3 "/var/local/www/db/moode-sqlite3.db" "DROP TRIGGER IF EXISTS ro_columns"
sudo sqlite3 "/var/local/www/db/moode-sqlite3.db" "UPDATE cfg_hash SET VALUE = '$(md5sum  /etc/nginx/nginx.conf | cut -d " " -f1)' WHERE PARAM = '/etc/nginx/nginx.conf'"
sudo sqlite3 "/var/local/www/db/moode-sqlite3.db" "CREATE TRIGGER ro_columns BEFORE UPDATE OF param, value, [action] ON cfg_hash FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'read only'); END;"

    - Reboot.


Hi TookaFace,

Is this the complete instructions? I am trying to install PiHole in Moode as well. Do I need to install the Nginx web server first? When I ran your first command line, I get the error "unable to update package cache. Please try sudo apt-get update"

I have moode 7.3 on RPi4B

Thanks.
Reply


Messages In This Thread
moOde and Pi-Hole on Nginx - by TookaFace - 11-30-2019, 04:37 PM
RE: moOde and Pi-Hole on Nginx - by Jempie - 06-19-2020, 05:25 AM
RE: moOde and Pi-Hole on Nginx - by TookaFace - 06-19-2020, 09:23 AM
RE: moOde and Pi-Hole on Nginx - by TookaFace - 08-19-2020, 02:12 PM
RE: moOde and Pi-Hole on Nginx - by LowkeyFlex - 01-14-2021, 05:33 PM
RE: moOde and Pi-Hole on Nginx - by TookaFace - 01-14-2021, 05:44 PM
RE: moOde and Pi-Hole on Nginx - by Prince - 01-14-2021, 07:00 PM
RE: moOde and Pi-Hole on Nginx - by TookaFace - 01-14-2021, 09:25 PM
RE: moOde and Pi-Hole on Nginx - by felichas - 02-21-2021, 10:20 PM
RE: moOde and Pi-Hole on Nginx - by felichas - 02-22-2021, 08:09 AM
RE: moOde and Pi-Hole on Nginx - by TookaFace - 02-22-2021, 08:06 AM
RE: moOde and Pi-Hole on Nginx - by TookaFace - 02-22-2021, 08:45 AM
RE: moOde and Pi-Hole on Nginx - by felichas - 02-22-2021, 05:56 PM
RE: moOde and Pi-Hole on Nginx - by Daksha - 03-31-2021, 05:42 PM
RE: moOde and Pi-Hole on Nginx - by pyhfsg - 09-29-2021, 03:43 AM
RE: moOde and Pi-Hole on Nginx - by DRONE7 - 09-29-2021, 04:23 AM
RE: moOde and Pi-Hole on Nginx - by TookaFace - 09-29-2021, 02:40 PM
RE: moOde and Pi-Hole on Nginx - by pyhfsg - 09-30-2021, 11:49 AM
RE: moOde and Pi-Hole on Nginx - by pyhfsg - 09-30-2021, 12:06 PM
RE: moOde and Pi-Hole on Nginx - by pyhfsg - 09-30-2021, 12:35 PM
RE: moOde and Pi-Hole on Nginx - by Prince - 02-02-2023, 06:17 PM

Forum Jump: