Welcome! Log In Create A New Profile

Advanced

Nginx proxy mail with LDAP authentification

Posted by pamplemousse 
Nginx proxy mail with LDAP authentification
April 22, 2024 11:07AM
Hello all,

I would like to implement a proxy mail with LDAP authentification or otherwise a local authentification.

I tried this module but it doesn't works :
https://github.com/nginxinc/nginx-ldap-auth
I'm getting theses errors :
" using username/password from authorization header"
""GET /auth-proxy HTTP/1.0" 401 -"

Also, I tried to deleguate the authentification to the backend mail server but it's not the final goal.

My config :


# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;

# Logs
error_log /var/log/nginx/error.log debug;
error_log /var/log/nginx/error.log notice;
error_log /var/log/nginx/error.log info;

pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
worker_connections 1024;
multi_accept on;
}


mail {
server_name <proxynameserver>;

#Enables or disables the passing of the XCLIENT command
xclient off;

#Authentification configuration
#Directive original ci-dessous
auth_http http://127.0.0.1:8080/mail/auth;
auth_http_pass_client_cert on;
smtp_auth login plain external;

#SSL configuration
#ssl on;
ssl_certificate <pathcertificate>/nginx.pem;
ssl_certificate_key <pathprivatekey>/server.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
#Directive original ci-dessous
#ssl_ciphers HIGH:!aNULL:!MD5;
ssl_ciphers ALL:!aNULL:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;

server {
listen <ipproxy>:465 ssl;
protocol smtp;
}
}

http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
tcp_nopush on;
keepalive_timeout 65;
types_hash_max_size 4096;

include /etc/nginx/mime.types;
default_type application/octet-stream;

# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;

server {
listen 80;
listen [::]:80;
server_name <proxynameserver>;
root /usr/share/nginx/html;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

location / {
try_files $uri $uri/ =404;

auth_basic " Restricted Content ";
auth_basic_user_file /etc/nginx/.htpasswd;
}

error_page 404 /404.html;
location = /404.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}

}


server {
listen 127.0.0.1:8080;
server_name <proxynameserver>;

location = /mail/auth {

add_header Auth-Server <mailservername>;
add_header Auth-Port 465;
add_header Auth-Method: plain;
add_header Auth-User: <user>;
add_header Auth-Pass: <password>;
add_header Auth-Protocol: smtp;
add_header Client-IP: <ipproxy>;
add_header Client-Host: <proxynameserver>;
add_header Auth-SSL: on;
add_header Auth-SSL-Protocol: TLSv1.3;
add_header Auth-SSL-Verify: SUCCESS;

return 204;
}
}
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 190
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready