Thank you for your donation!


[How to do instruction] moOde and Pi-Hole on Nginx
#1
Just a little how-to for running Pi-Hole with moOde on Nginx web server (based on moOde 6.4 image).

    - 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:
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'"

    - Reboot.
Reply


Forum Jump: