Nginx wrapup with htpasswd basic auth, set the nginx.conf to your likings (if you use the newer raspberry pi's you can change the default from 1 to 2 or 4 worker processes)

master
Michiel van Es 8 years ago
parent 1b91985355
commit 710cc2c1dd

@ -0,0 +1,33 @@
. apt-get -y install nginx php5-fpm apache2-utils #install necessary packages
. systemctl disable lighttpd #disable lighttpd at startup
. systemctl enable php5-fpm #enable php5-fpm at startup
. systemctl enable nginx #enable nginx at startup
. edit /etc/nginx/conf.d/default to:
----
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.php;
server_name _;
autoindex off;
location / {
expires max;
return 204 'pixel';
}
location /admin{
root /var/www/html;
index index.php;
auth_basic "Restricted"; #For Basic Auth
auth_basic_user_file /etc/nginx/.htpasswd; #For Basic Auth
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}
----
. htpasswd -c /etc/nginx/.htpasswd exampleuser #create username for authentication for the admin - we don't want other people in our network change our black and whitelist ;)
. service lighttpd stop #stop default lighttpd
. service php5-fpm start #start php5-fpm daemon
. service nginx start #start nginx webserver
Loading…
Cancel
Save