kvspb / nginx-auth-ldap

LDAP authentication module for nginx
BSD 2-Clause "Simplified" License
739 stars 253 forks source link

How to Integrate LDAP with upstream and Proxy #220

Closed dhristov1 closed 5 years ago

dhristov1 commented 5 years ago

So, guys, I have this config. I'm thinking where to put that LDAP configuration because in the example is shown without proxy pass and upstream. I'm fairly new to Nginx and be happy if u can give me a hint. How the configuration should look like?

upstream sdvcontgenp01.example.net { server 192.168.20.69:8080; } server { listen 80; server_name sdvcontgenp01.example.net;

REDIRECT (Putting https)

    rewrite     ^(.*)   https://$host$1 permanent;
}
    server {
    listen                  443;
    ssl                     on;
    ssl_certificate         /opt/example-8080/sdvcontgenp01.example.net.cert;
    ssl_certificate_key     /opt/example-8080/sdvcontgenp01.example.net.key;
    ssl_protocols TLSv1.1 TLSv1.2;
    ssl_ciphers 'TLS_RSA_WITH_AES_256_CBC_SHA256:TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256:TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA:AES256-SHA256:AES128+EECDH:AES128+EDH:!aNULL';
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    server_name sdvcontgenp01.example.net;
    # Upload file size limit
    client_max_body_size    50m;
    # bypass tomcat for profile images
    location ~* /example/profile/[0-9]*/.*\.(jpg|jpeg|gif|png)$ {
        root /opt/synch/docs-branch/;
        rewrite /example/profile/([0-9]*)/(.*) /$1/$2 break;
    }

    # bypass tomcat for company logos
    location ~* /example/logo/[0-9]*/.*\.(jpg|jpeg|gif|png)$ {
            root /opt/synch/docs-branch/;
            rewrite /example/logo/([0-9]*)/(.*) /$1/$2 break;
    }

    # bypass tomcat for company theme
    location ~* /example/companyTheme/theme/[0-9]+_.*\.css$ {
            root /opt/synch/docs-branch/;
            rewrite /example/companyTheme/theme/([0-9]+)_.*.css /$1/$1.css break;
    }

    location /example {
    proxy_set_header X-Real-IP  $remote_addr;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass http://192.168.20.69:8080/example/;
           }

    location /example/api {
    proxy_set_header X-Real-IP  $remote_addr;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass http://192.168.20.69:8080/example/api;
            }

    location / {
    proxy_set_header X-Real-IP  $remote_addr;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass http://192.168.20.69:8080/example/;
            }
    }