nginx集成LDAP

安装

git clone https://github.com/kvspb/nginx-auth-ldap.git
wget http://nginx.org/download/nginx-1.18.0.tar.gz
yum -y install openldap-devel pcre-devel openssl-devel
tar -zxvf nginx-1.18.0.tar.gz
cd nginx-1.18.0/
./configure --prefix=/opt/nginx \
--add-module=/root/nginx-auth-ldap-master --add-module=/root/ngx_http_geoip2_module-master \
--with-http_addition_module --with-http_stub_status_module --with-http_realip_module \
--with-http_ssl_module --with-http_v2_module \
--with-http_gunzip_module --with-http_gzip_static_module
make
make install

配置

user  root;
worker_processes  auto;

worker_rlimit_nofile 102400;
events {
    worker_connections  10240;
    multi_accept on;
    use epoll;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
                      
    set_real_ip_from 0.0.0.0/0;
    real_ip_header X-Forwarded-For;
    real_ip_recursive on;

    sendfile       on;
    tcp_nopush     on;
    keepalive_timeout  65;
    gzip on;
    gzip_min_length 1k;
    gzip_buffers 4 32k;
    gzip_comp_level 2;
    gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    gzip_vary on;
    gzip_disable "MSIE [1-6]\.";
    client_max_body_size 100m;
    client_body_buffer_size 50m;

    ldap_server openldap {
        url ldap://172.21.16.179:389/cn=accounts,dc=o,dc=test,dc=com?uid?sub?(objectClass=person);
        binddn "uid=keycloakbot,cn=users,cn=accounts,dc=o,dc=test,dc=com";
        binddn_passwd "12345678";
        group_attribute uniquemember;
        group_attribute_is_dn on;
        require valid_user;
    }

    include /opt/nginx/conf/conf.d/*.conf;
}

conf.d/prometheus.conf

#prod prometheus
server {
    listen 19090;
    server_name 47.115.78.17;

    proxy_set_header X-Forwarded-For $remote_addr;

    location / {
         auth_ldap "test SSO";
         auth_ldap_servers openldap;
         #auth_basic "test PROD WARNING";
         #auth_basic_user_file /opt/nginx/passwd.db;
         proxy_pass         http://172.23.13.67:31269;
         proxy_set_header   Host $host;
         proxy_set_header   X-Real-IP $remote_addr;
         proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header   X-Forwarded-Host $server_name;
         proxy_read_timeout  1200s;
    }
}
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值