V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
qwefdrt
V2EX  ›  NGINX

求助, Nginx 反向代理 Exchange(IIS)遇到的问题。

  •  
  •   qwefdrt · 2018-11-29 00:20:11 +08:00 · 4304 次点击
    这是一个创建于 1947 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我想在两台 Exchange2016 前加入 nignx ( Tengine )做反向代理和负载均衡。 现在遇到的问题是:OWA 可以正常访问,但是 Outlook ( Mac 端)配置时一直弹窗提示输入用户名和密码,正确输入后说用户名和密码错误。Windows 端也是类似的错误。

    配置如下: #mail.test.com.conf

    upstream  test {
        server xx.xx.xx.xx;
        server xx.xx.xx.xx;
    }
    server {
        listen  443 ssl;
        server_name  mail.test.com autodiscover.test.com;
        include rules/ssl.conf; # 设置了服务器证书
    
        location / {
            index  index.php;
            proxy_pass  http://test/;
    		proxy_http_version      1.1;
    		proxy_set_header        Connection "";
    		proxy_next_upstream         error timeout;
    		proxy_set_header        Host $host;
    		proxy_set_header        X-Real-IP $remote_addr;
    		proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    		proxy_set_header        X-Forwarded-Proto $scheme;
    		proxy_ignore_client_abort on;
        }
    }
    
    server {
        listen  80;
        server_name  mail.test.com autodiscover.test.com;
        return 301 https://$host$request_uri;
    }
    

    #nginx.conf

    worker_processes auto;
    worker_cpu_affinity auto;
    
    events {
        worker_connections  65535;
        use epoll;
    }
    
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
    
        server_names_hash_bucket_size 128;
    
        sendfile        on;
        tcp_nopush      on;
        tcp_nodelay     on;
        gatekeeper_module on;
    
        fastcgi_connect_timeout 5;
        fastcgi_send_timeout 10;
        fastcgi_read_timeout 10;
        fastcgi_buffer_size 64k;
        fastcgi_buffers 4 64k;
        fastcgi_busy_buffers_size 128k;
        fastcgi_temp_file_write_size 128k;
    
        keepalive_timeout  60;
        keepalive_requests 1024;
        client_header_buffer_size 4k;
        large_client_header_buffers 4 32k;
        client_max_body_size 10m;
        client_body_buffer_size 512k;
        client_body_timeout 30;
        client_header_timeout 10;
        send_timeout 240;
        proxy_connect_timeout   10s;
        proxy_send_timeout      50s;
        proxy_read_timeout      60s;
        proxy_buffers           64 8k;
        proxy_busy_buffers_size    128k;
        proxy_temp_file_write_size 64k;
        proxy_redirect off;
    
        gzip on;
        gzip_min_length 1k;
        gzip_buffers 4 16k;
        gzip_http_version 1.0;
        gzip_comp_level 2;
        gzip_types text/plain application/x-javascript text/css text/xml 	   application/xml+css application/json text/javascript;
        gzip_vary on;
    
        log_format main '$server_addr\t$host\t'
                     '$remote_addr\t$remote_user\t$http_x_forwarded_for\t'
                     '$time_local\t'
                     '$scheme\t$request\t'
                     '*#06#$status*#06#\t$upstream_status\t'
                     '$request_time\t$upstream_addr\t$upstream_response_time\t'
                     '$request_length\t$bytes_sent\t'
                     '$operationid\t$HTTP_DIDI_HEADER_SPANID\t'
                     '$http_referer\t$http_cookie\t$http_user_agent\t'
                     '$limit_rate';
    
        access_log logs/access.log  main;
    
        set_real_ip_from 10.0.0.0/8;
        set_real_ip_from 100.64.0.0/10;
        real_ip_header X-Real-IP;
    
        include conf.d/*.conf;
        include sites-enabled/*;
    
    }
    

    另:当 Exchange 中的认证方式从 Windows 认证改成 Basic 认证后,MAC 端 Outlook 配置成功了,但是 Win 端还不行。

    11 条回复    2023-09-01 14:15:04 +08:00
    likuku
        1
    likuku  
       2018-11-29 00:29:13 +08:00
    这样吧,建议你换用 haproxy,直接使用 tcp 模式来代理,这样看起来就像是端口转发,不会干扰到具体协议的通讯。

    毕竟涉及到 ssl 证书什么,真的很烦...
    gstqc
        2
    gstqc  
       2018-11-29 00:44:42 +08:00 via Android
    outlook 用的是 IMAP pop SMTP
    不是 443
    qwefdrt
        3
    qwefdrt  
    OP
       2018-11-29 00:45:56 +08:00
    @likuku 的确啊,但是老板要求七层转发。。。tcp 的话我已经用 LVS 搭了一套,但是还是想解决七层这个问题的。
    geelaw
        4
    geelaw  
       2018-11-29 00:56:18 +08:00 via iPhone   ❤️ 1
    @gstqc #2 AutoDiscover 和 OWA 都是用 HTTPS 的。而且主协议应该是 Exchange 而不是 IMAP/SMTP (我记得很久以前的 macOS 版没有 Exch 还是 EAS 来着,太久远忘记了)。

    软黑还有 2 分钟到达战场。
    vibbow
        5
    vibbow  
       2018-11-29 01:37:08 +08:00
    https://testconnectivity.microsoft.com/

    LZ 可以用这个工具测试你的 exchange 配置的
    gstqc
        6
    gstqc  
       2018-11-29 08:39:29 +08:00 via Android
    upstream 里加上 ip_hash; 试试
    可能两个请求分配到不同后端了

    官方文档:
    https://nginx.org/en/docs/http/ngx_http_upstream_module.html#ip_hash
    imbushuo
        7
    imbushuo  
       2018-11-29 09:12:17 +08:00
    @geelaw Outlook for Mac 现在走的 EWS
    qwefdrt
        8
    qwefdrt  
    OP
       2018-11-29 09:17:44 +08:00
    @gstqc 我也确实想过这个问题,但是我只转发给一台服务器也是这样的
    likuku
        9
    likuku  
       2018-11-29 10:53:40 +08:00
    @qwefdrt 以前用了 exchange 好几年,基本每年一次被迫停机维护(至少 1 整天),
    最后大家实在是烦了,切到 postfix + imap 彻底清爽了,共享通讯录,忘记怎么搞的了。
    brando
        10
    brando  
       2018-12-26 22:05:20 +08:00
    本人也遇到这样的问题,只要是 windows 下的客户端就会一直弹出输入用户名和密码,其他系统客户端就无此现象。另外如果直接解析到该服务器,不是代理则没有,可以直接用 windows 下的客户端。估计是 nginx 不支持 rpc over http。
    Izual_Yang
        11
    Izual_Yang  
       209 天前
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1017 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 19:25 · PVG 03:25 · LAX 12:25 · JFK 15:25
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.