mail {
server_name блаблабла;
auth_http 127.0.0.1:8080/auth.php;
proxy_pass_error_message on;
ssl_certificate /etc/letsencrypt/live/блаблабла/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/блаблабла/privkey.pem; # managed by Certbot
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
xclient off;
include /etc/nginx/mail.d/*.conf;
error_log /var/log/nginx/auth_error.log;
}
server {
listen внешний:995 ssl;
protocol pop3;
pop3_auth apop plain cram-md5;
starttls off;
}
server {
listen внешний:465 ssl;
protocol smtp;
smtp_auth login plain cram-md5;
proxy_smtp_auth off;
starttls off;
}
Авторизация:
log_format proxy_auth
'$http_client_ip - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" AuthStatus:"$auth_status"';
server {
listen 127.0.0.1:8080;
root /srv/www/html/nginx-mail-auth-ldap;
index index.php index.html;
location ~ \.php$ {
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;
#lua
set $auth_status "";
header_filter_by_lua '
ngx.var.auth_status = ngx.resp.get_headers()["Auth-Status"]
';
#
}
access_log /var/log/nginx/auth_access.log proxy_auth;
error_log /var/log/nginx/auth_error.log;
}