Mat*_*ley 5 configuration tomcat subdomain haproxy
我是 StackExchange 的新手,正在尝试寻找一些有关配置问题的帮助。我需要为 HAProxy 创建一个配置,它允许我将 Tomcat 应用程序上下文路径动态代理到子域。子域/路径不能硬编码,应设置为变量。我已经查看了整个站点中建议的其他内容,但没有一个涉及这个特定问题。到目前为止,我已经从各种现有建议中汇总了此配置。
这就是我需要的。
http://site1.domain.com/pathhttp://<ip>:8080/site1/path当 tomcat 应用程序返回指向资产的链接时,它们也会有一个需要重定向的路径。
https://site1.example.com/site1/image.jpghttps://site1.example.com/image.jpg我已经使用本网站的示例和其他指南获得了这么多,但我在这方面的知识有限。我不确定如何删除路径中的 site1。
# Frontend Definition
frontend tomcat_contexts
bind *:80
bind *:443 ssl crt /etc/haproxy/cert.pem
acl http ssl_fc,not
http-request redirect scheme https if http
reqadd X-Forwarded-Proto:\ https
default_backend cluster
# Backend Definition
backend cluster
balance roundrobin
cookie JSESSIONID prefix nocache
# Perform Subdomain url rewrite
http-request set-var(req.subdomain) req.hdr(host),lower,regsub(\.example\.com$,) if { hdr_end(host) -i .domain.com }
http-request set-path /%[var(req.subdomain)]%[path] if { var(req.subdomain) -m found }
http-request set-header Host example.com if { var(req.subdomain) -m found }
# Cluster machines
server app01 192.168.69.181:8080 check cookie app01
server app02 192.168.69.182:8080 check cookie app02
Run Code Online (Sandbox Code Playgroud)
欢迎大家提出意见。
| 归档时间: |
|
| 查看次数: |
1302 次 |
| 最近记录: |