bobthecow / genghis

The single-file MongoDB admin app
http://genghisapp.com
MIT License
1.45k stars 166 forks source link

Cant setup on nginx and/or password protect the directory #225

Closed corporationsruleyourmom closed 7 years ago

corporationsruleyourmom commented 7 years ago

Hey! Love this database management tool!

Unfortunately I cant get it to work on Nginx with a password protected directory. If there is an easier way of doing this please let me know!

If I install via gem Genghis works perfectly with Nginx using the default port 5678 but I cant password protect it (Eg. http://serveraddress:5678). Soo instead I wget the Genghis zip and unzip it to a folder called mongodb in the Nginx html root directory. Maybe there are some php5 prerequisites I'm missing? I seem to remember installing something via pear when doing this with Apache...

Here is my Nginx config file:

server {
        location /mongodb {

        #Basic Auth
        auth_basic "Restricted Content";
        auth_basic_user_file /etc/nginx/.htpasswd;

        #fastcgi_pass 127.0.0.1:9000;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        #include snippets/fastcgi-php.conf;
        include fastcgi_params;

        fastcgi_split_path_info ^/(mongodb)(/?.+)$;
        #fastcgi_param SCRIPT_FILENAME $document_root/mongodb/genghis.php;
        #fastcgi_param SCRIPT_NAME /mongodb/genghis.php;
        #fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

Is there something I'm missing?

corporationsruleyourmom commented 7 years ago

I figured it out! I forgot to install the php plugin (doh!) for mongodb and file ownership/permissions. This link should really be in the wiki section...

Change ownership/permissions of web files:

sudo chown -R www-data:www-data /usr/share/nginx/html/mongodb/*

sudo chmod -R 0755 /usr/share/nginx/html/mongodb/*

Also, in /etc/nginx/sites-enabled/default you have to enable php

        # Add index.php to the list if you are using PHP
        index index.php index.html index.htm index.nginx-debian.html;

        # Something like this also helps too
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
bobthecow commented 7 years ago

Please update the wiki with whatever info you needed to get it going :)