nginx反向代理SMTP,POP3,IMAP jsp认证

作者: admin 分类: nginx 发布时间: 2012-11-22 15:58 ė 6 1条评论

nginx 配置

————————————————————-

mail {
auth_http 127.0.0.1:8080/auth.jsp;
pop3_capabilities “TOP” “USER”;
imap_capabilities “IMAP4rev1” “UIDPLUS”;

server {
listen 110;
protocol pop3;
proxy on;
}

server {
listen 143;
protocol imap;
proxy on;
}
server {
listen 25;
protocol smtp;
#smtp_auth plain;
xclient off;
proxy on;
}
}

————————————————auth.jsp——————————————

<%@ page language=”java” contentType=”text/html; charset=UTF-8″
pageEncoding=”UTF-8″%>
<%
String userName= request.getHeader(“auth-user”);
String passwd=request.getHeader(“auth-pass”);
String protocol=request.getHeader(“auth-protocol”);
if(protocol!=null){
protocol=protocol.toLowerCase();
}

String server=”192.168.0.9″; //根据用户的所在地,修改相应的邮件服务器内网IP
String port=”25″;
if (“imap”.equals(protocol)) {
port=”143″;
}
else if (“smtp”.equals(protocol)) {
port=”25″;
}else if (“pop3”.equals(protocol)) {
port=”110″;
}
//连接LDAP或者其他方式,判断用户的账号密码是否正确,如果错误 response.setHeader(“Auth-Status”,”ERROR”);

response.setHeader(“Auth-Status”,”OK”);//用户账号密码正确
response.setHeader(“Auth-Server”,server);
response.setHeader(“Auth-Port”,port);
response.setHeader(“Auth-Pass”,passwd);
response.setHeader(“Auth-User”,userName);

%>

文件打包下载:nginx_mail

本文出自weicms.net,转载时请注明出处及相应链接。

本文永久链接: http://www.weicms.net/2012/11/22/nginx_mail.html

0

一条评论

  1. rian 2013 年 4 月 9 日 06:01

    高人!

Ɣ回顶部