让 HAPROXY 在用户浏览器会话中将 http 重定向到 https

让 HAPROXY 在用户浏览器会话中将 http 重定向到 https

我们目前正在使用互联网云提供商来托管我们的 SaaS 平台。该平台由防火墙 -> 云提供商 SLB -> -> Apache Web 服务器 -> HAPROXY SLB -> Liferay 平台组成

由于云提供商 SLB 存在问题,我们不得不使用 HAPROXY,这意味着我们无法使用它来平衡 Liferay 平台应用程序的负载。

我已经在我们的安全层中实现了 HAPROXY,并且它似乎能够相当充分地实现请求负载平衡。

但是在测试期间我们遇到了一个功能问题,即从 Web 门户选择一个子菜单导致应用程序挂起,使用 http 分析器我们看到传回用户浏览器的请求是 http 格式的,通过与软件供应商讨论得知,Liferay 应用程序有一些硬编码的 http 链接,而其他客户已经通过使用物理 NLB(如 F5)并将 http 流量重定向到 https 来解决此问题。

HAPROXY 日志中的条目内容如下:

haproxy[2717]: haproxy[2717]: <Apache Web Agent>:37957 [11/Apr/2013:08:07:00.128] http-uapi uapi/<ServerName> 0/0/0/9/10 200 4912 - - ---- 4/2/1/2/0 0/0 "GET /servicedesk/controller?docommand=renderradform&!key=esd_sfb001_frm_feedback_forms_list&isportalintegratedmode=true&USR=joe.bloggs%40gmail.com&_dc=1365667773097&redirecturl=controller%3Fdocommand%3Drenderbody%26%21key%3DESD_SFB001_FRM_FEEDBACK_FORMS_LIST%26isportalintegratedmode%3Dtrue&sso_token=ALiYv2UqzLsAhSw1ZchRDlCHlq44Bhj9&ONERROR=%2Fweb%2Fjsp%2Fapps%2Fportal-integration-error.jsp&itype=login&slicetoken=NW51O%242aRo%2C_Zz%2476P_9DTtnFmz6%28bhk&AUTOFORWARDURL=controller%3Fdocommand%3Drenderbody%26%21key%3DESD_SFB001_FRM_FEEDBACK_FORMS_LIST%26isportalintegratedmode%3Dtrue&LOGINPAGE=https%3A%2F%2F<FQDN of Web Portal>%2Fweb%2F4732cf01-82c3-4bc5-b6c9-552253e672cf%2Fworkflow-tools&appid=1&!uid=1&!redownloadToken=7.0.3.1.1363611301.0&userlocale=en_US&!datechanged=2012-05-18%2015:05:31.38 HTTP/1.1"
:37957 [11/Apr/2013:08:07:00.128] http-uapi uapi/<ServerName> 0/0/0/9/10 200 4912 - - ---- 4/2/1/2/0 0/0 "GET /servicedesk/controller?docommand=renderradform&!key=esd_sfb001_frm_feedback_forms_list&isportalintegratedmode=true&USR=joe.bloggs%40gmail.com&_dc=1365667773097&redirecturl=controller%3Fdocommand%3Drenderbody%26%21key%3DESD_SFB001_FRM_FEEDBACK_FORMS_LIST%26isportalintegratedmode%3Dtrue&sso_token=ALiYv2UqzLsAhSw1ZchRDlCHlq44Bhj9&ONERROR=%2Fweb%2Fjsp%2Fapps%2Fportal-integration-error.jsp&itype=login&slicetoken=NW51O%242aRo%2C_Zz%2476P_9DTtnFmz6%28bhk&AUTOFORWARDURL=controller%3Fdocommand%3Drenderbody%26%21key%3DESD_SFB001_FRM_FEEDBACK_FORMS_LIST%26isportalintegratedmode%3Dtrue&LOGINPAGE=https%3A%2F%2F<FQDN of Web Portal>%2Fweb%2F4732cf01-82c3-4bc5-b6c9-552253e672cf%2Fworkflow-tools&appid=1&!uid=1&!redownloadToken=7.0.3.1.1363611301.0&userlocale=en_US&!datechanged=2012-05-18%2015:05:31.38 HTTP/1.1"

相应的HTTP浏览器条目显示:

http://<FQDN of ServiceDesk>/servicedesk/controller?docommand=renderradform&!key=esd_org019_frm_contact_list&isportalintegratedmode=true&USR=joe.bloggs%40gmail.com&_dc=1365665987887&redirecturl=controller%3Fdocommand%3Drenderbody%26%21key%3DESD_ORG019_FRM_CONTACT_LIST%26isportalintegratedmode%3Dtrue&sso_token=3NxsXYORMPp32SwL8ftVUCMH2QdWLH82&ONERROR=%2Fweb%2Fjsp%2Fapps%2Fportal-integration-error.jsp&itype=login&slicetoken=NW51O%242aRo%2C_Zz%2476P_9DTtnFmz6%28bhk&AUTOFORWARDURL=controller%3Fdocommand%3Drenderbody%26%21key%3DESD_ORG019_FRM_CONTACT_LIST%26isportalintegratedmode%3Dtrue&LOGINPAGE=https%3A%2F%2F<FQDN of Web Portal>>%2Fweb%2F4732cf01-82c3-4bc5-b6c9-552253e672cf%2Fapplication-setup&appid=1&!uid=1&!redownloadToken=7.0.3.1.1363611301.0&userlocale=en_US&!datechanged=2012-10-26%2019:00:25.08

通过阅读论坛和其他网站,我们似乎应该使用 HAPROXY 将流量重定向到 https,但是无论我怎么尝试,我都无法让它工作。

这是我们的 HAPROXY 配置:

global

    log         127.0.0.1 local2

    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon

    stats socket /var/lib/haproxy/stats

defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000

frontend http-openfire
    bind *:7070
    default_backend openfire

backend openfire
    balance     roundrobin
    server  <serverName> <IPv4 Address>:7070 check
    server  <serverName> <IPv4 Address>:7070 check

frontend http-uapi
    bind *:7080
    default_backend uapi

backend uapi
    balance     roundrobin
    server  <serverName> <IPv4 Address>:7080 check
    server  <serverName> <IPv4 Address>:7080 check

frontend http-sec
    bind *:8080
        default_backend sec

backend sec
     balance     roundrobin
     server  <serverName> <IPv4 Address>:8080 check
     server  <serverName> <IPv4 Address>:8080 check

frontend http-wall
    bind *:9080
    default_backend wall

backend wall
    balance     roundrobin
    server  <serverName> <IPv4 Address>:9080 check
    server  <serverName> <IPv4 Address>:9080 check

frontend http-xmpp
    bind *:9090
    default_backend xmpp

backend xmpp
    balance     roundrobin
    server  <serverName> <IPv4 Address>:9090 check
    server  <serverName> <IPv4 Address>:9090 check

frontend http-aim
    bind *:10080
    default_backend aim

backend aim
    balance     roundrobin
    server  <serverName> <IPv4 Address>:10080 check
    server  <serverName> <IPv4 Address>:10080 check

frontend http-servicedesk
    bind *:8081
        default_backend servicedesk

backend servicedesk
     balance     roundrobin
     server  <serverName> <IPv4 Address>:8081 check
     server  <serverName> <IPv4 Address>:8081 check

listen stats :1936
    mode http
    stats enable
    stats hide-version
    stats realm Haproxy\ Statistics
    stats uri /
    stats auth haproxy:<Password>

我尝试过按照列出的文章发布https://stackoverflow.com/questions/13227544/haproxy-redirecting-http-to-https-sslhttp://parsnips.net/haproxy-http-to-https-redirect/但这并没有什么区别。

我这样做是否正确,还是我们只是在试图实现不可能的事情?我希望我只是个白痴,你们中有人能给我指明正确的方向。

答案1

请参阅我在此主题中的回答:

Apache SSL 反向代理破坏了 Liferay 身份验证

如果你想“修复”Liferay 硬编码 http。

相关内容