nginx
重定向
server {
listen 127.0.0.1:1001;
root /var/www/html;
index index.html;
rewrite ^/(.*)$ http://IP/$1 permanent;
}
账号密码登录
1 htpasswd
server {
listen 127.0.0.1:1001;
root /var/www/html;
index index.html;
location / {
auth_basic "Please input username and password.";#提示信息
auth_basic_user_file /test/htpasswd;}#账户密码
}
#生成账户密码
htpasswd -cb /test/htpasswd ceshi 123456
2 ldap
/etc/nginx/conf.d/proxy.conf
ldap_server xxx-ldap {
url ldap://ldap服务器ip:port/DC=xxx,DC=com?cn?sub?(objectClass=person);
binddn "cn=xxx,dc=xxx,dc=xxx";
binddn_passwd "binddn密码";
group_attribute uniquemember;
group_attribute_is_dn on;
require valid_user;
}
server {
listen 80;
server_name localhost;
location /status {
stub_status on;
auth_ldap "Forbidden";
auth_ldap_servers xxx-ldap;
}
借鉴:
https://www.jianshu.com/p/bf0f8549352c
https://blog.csdn.net/h330531987/article/details/79889416