haproxy重定向到Tomcat应用

时间:2017-09-07 14:02:46

标签: tomcat haproxy

我在项目中使用Haproxy 1.6。

我有一个tomcat aplication,位于tomcat-node.local/MyApp

我创建了一个dns somedomainname,并希望将所有请求重定向到tomcat-node.local/MyApp

我的haproxy conf:

frontend http-in
    bind *:80
    reqadd X-Forwarded-Proto:\ http
    default_backend application-backend

frontend https-in
    bind *:443 ssl crt /pathtopem/key.pem
    acl portal2 hdr_dom(host) -i somedomainname

    mode http
    rspadd Strict-Transport-Security:\ max-age=31536000;\ includeSubDomains;\ preload
    rsprep ^Set-Cookie:\ (.*) Set-Cookie:\ \1;\ Secure if { ssl_fc }
    reqadd X-Forwarded-Proto:\ https
    redirect scheme https if !{ ssl_fc }
    use_backend portal2-backend if portal2
    default_backend application-backend

backend portal2-backend
    mode http
    balance leastconn
    option httpclose
    option forwardfor
    stats uri /admin?stat
    stats enable
    cookie JSESSIONID prefix
    http-request set-header X-Forwarded-Port %[dst_port]
    http-request add-header X-Forwarded-Proto https if { ssl_fc }
    redirect scheme https if !{ ssl_fc }


    server node1.domain.local 192.168.0.1:8080 maxconn 32 check inter 5000 cookie node1.domain.local
    server node2.domain.local 192.168.0.2:8080 maxconn 32 check inter 5000 cookie node2.domain.local

这种方法完美无缺。 但我需要在网址路径中指定MyApp来获取我的应用:http://somedomainname/MyApp --> http://tomcat-node.local/MyApp

我需要重定向所有请求: http://somedomainname/%Someurl% --> http://tomcat-node.local/MyApp/%SomeUrl%

我该怎么做?

0 个答案:

没有答案