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
#2
(11-30-2019, 04:37 PM)TookaFace Wrote: Just a little how-to for running Pi-Hole with moOde on Nginx web server (based on moOde 6.4/6.4.1 version).

    - 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 ?
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 snippets/fastcgi-php.conf;
               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:
Code:
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html

    - 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 for moOde 6.4:
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 ACTION = 'warning' WHERE PARAM = '/etc/nginx/nginx.conf'"


\\ ONLY FOR 6.4.1 - START
    - Update moOde database for moOde 6.4.1:
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 ACTION = 'warning' 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;"

Code:
sudo nano -l /var/www/inc/playerlib.php

Comment lines 217, 218, 219, 220
Code:
//if ($row['id'] < 8 && $row['action'] !== 'exit') {
//      $_SESSION['ic_return_code'] = '2'; 
//      return false; 
//}
\\ ONLY FOR 6.4.1 - END

    - Reboot.

Hi TokeaFace,

does it work for version 6.2.1 ?

thanks Jempie
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: