- 利用 Nginx 作為 Web 平台,實作 Web 站台帳密登入機制
- 請先安裝 Nginx Web 平台!可參考這一篇文章!
-
利用 yum 進行相關套件安裝:
#yum -y install httpd-tools
-
設定帳號與密碼:
#htpasswd -c /etc/nginx/.htpasswd nginx (查看密碼內容:) # cat /etc/nginx/.htpasswd
-
修改 Nagios 設定檔 /etc/nginx/nginx.conf:
# vim /etc/nginx/nginx.conf (追加下列設定參數:) auth_basic "Private Property"; auth_basic_user_file /etc/nginx/.htpasswd;
-
重新啟動 Nagios:
# systemctl reload nginx
-
限制指定的目錄:
#vim /etc/nginx/conf.d/default.conf (加入下列設定參數) location ~ ^/admin/.* { root /usr/share/nginx/html; index index.php index.html index.htm; location ~ \.php$ { try_files $uri = 404; fastcgi_pass unix:/var/opt/remi/php70/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } auth_basic "Administrator Login"; auth_basic_user_file /usr/share/nginx/html/.htpasswd; }
- http://tonyhack.familyds.net/wordpress/?p=1998