How to get username from the form and pass it through nginx?
See original GitHub issueHi, I want to extract username from the login form, and pass it through nginx. the nginx-ldap-auth-daemon.py, backend-sample-app.py, nginx-ldap-auth-daemon-ctl-rh.sh are default. nginx.conf:
error_log logs/error.log debug;
events {
worker_connections 10240;
}
http {
proxy_cache_path cache/ keys_zone=auth_cache:10m;
upstream backend {
server 127.0.0.1:9000;
#server 127.0.0.1:5601;
}
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
server {
listen 8081;
location / {
auth_request /auth-proxy;
error_page 401 =200 /login;
proxy_set_header X-PROXY-USER $username; //how to get the username in nginx?
#proxy_pass http://backend/;
proxy_pass http://localhost:5601;
}
location /login {
proxy_pass http://backend/login;
proxy_set_header X-Target $request_uri;
}
location = /auth-proxy {
internal;
proxy_pass http://127.0.0.1:8888;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_cache auth_cache;
proxy_cache_valid 200 10m;
proxy_cache_key "$http_authorization$cookie_nginxauth";
proxy_set_header X-Ldap-URL "ldap://localhost:389";
proxy_set_header X-Ldap-BaseDN "dc=xinhua,dc=org";
proxy_set_header X-Ldap-BindDN "cn=Manager,dc=xinhua,dc=org";
proxy_set_header X-Ldap-BindPass "xxxxxx";
proxy_set_header X-CookieName "nginxauth";
proxy_set_header Cookie nginxauth=$cookie_nginxauth;
}
}
}
thank you in advance!
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
pass or write the username from Nginx into an app
I can see the user names in logs/nginx_shiny_access.log because of $remote_user . How can I get the user names in html file and...
Read more >tomcat - nginx proxy based on username
I'm using nginx as a proxy server in front of Tomcat instances. There's basic authentication set up, giving access to the demo page...
Read more >Restricting Access with HTTP Basic Authentication
You can restrict access to your website or some parts of it by implementing a username/password authentication. Usernames and passwords are taken from...
Read more >How To Set Up Password Authentication with Nginx on ...
To start out, we need to create the file that will hold our username and password combinations. You can do this by using...
Read more >Use nginx to Add Authentication to Any Application
Why Authenticate at the Web Server? · Using the nginx auth_request Module · Choosing an Auth Proxy · Configure Your Protected nginx Host...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I solved the problem thx 😃
@Howard-Chang how did you solve it? Can you brief it? I’m facing a similar situation for Nginx-LDAP authentication.
Also what should be provided in the nginx config for ? proxy_set_header X-Ldap-BindDN “cn=Manager,dc=xinhua,dc=org”; proxy_set_header X-Ldap-BindPass “9ol./;p0”;