配置nginx使用basic http认证方式
server {
#proxy server for gerrit
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:88 default ipv6only=on; ## listen for ipv6
index index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location / {
stub_status on;
auth_basic "Sign in";
auth_basic_user_file /home/public_internal/etc/nginx/httppassword;
proxy_pass http://yourhost:yourport;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
}
批量生成密码的原始明文文件格式如下:
admin:caoxudong
caoxudong:caoxudong
生成后的密码文件格式如下:
admin:$apr1$seLECBcl$GDtQCA59fxNagsmT5WiMe1
caoxudong:$apr1$oNZc/.kJ$vWQjk3G0mFenTFg6cJUU/1
使用脚本generate_password_for_nginx_auth_basic.sh
即可