ブログ - nginxでBASIC認証をつける
splunkのフロントをnginxで作って来たけれど,splunkのユーザとは別で基本認証を設定したい.ということでBASIC認証を設定する.
まずは,パスワードファイルを作成する.今回はsplunkというユーザ.
nginx.confには,次のように記載.
基本認証ファイルを設定して,nginxを再起動.
これで終了.
まずは,パスワードファイルを作成する.今回はsplunkというユーザ.
gaia:nginx server$ htpasswd -c htpasswd.splunk splunk🆑
New password:🔑
Re-type new password:🔑
Adding password for user splunk
gaia:nginx server$ cat /usr/local/etc/nginx/htpasswd.splunk🆑
splunk:$apr1$Ffk0WbFm$YS4CL1zFU4FDrOv1e.9i1.🈁
gaia:nginx server$
location /splunk/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_pass http://192.168.20.25:8000;
auth_basic "Please input";🈁
auth_basic_user_file /usr/local/etc/nginx/htpasswd.splunk;🈁
}
brew services top nginx;sleep 5;brew services start nginx