linux – HAproxy子域重定向

我拥有像xyz.com这样的域名,我正在尝试使用haproxy重定向子域名其他ip.

我在服务器上使用tomcat,并使用haproxy将端口80上的传入请求重定向到端口8080.

Like;

www.xyz.com -> 10.0.0.1

www.xyz.com/abc -> 10.0.0.2
  or  abc.xyz.com -> 10.0.0.2

为了进行此重定向,如何设置haproxy?

解决方法

在haproxy中,你进行重定向组合acl规则和重定向规则;您使用后端规则选择正确的服务器.

官方haproxy documentation不是很容易阅读,但它非常完整.

像这样的东西(只是一个草图给你一个想法):

frontend http-in
    mode              http
    bind              FRONTENDIP:80 # eg. 100.100.100.100:80

    default_backend   tomcat_server_2

    acl tomcat_1      hdr_end(host) -i www.xyz.com
    acl tomcat_2      hdr_end(host) -i abc.xyz.com
    acl tomcat_path   path_beg /abc/

    use_backend       tomcat_server_1 if tomcat_1 !tomcat_path

backend tomcat_server_1
    server tomcat1 10.0.0.1:8080 maxconn 1000

backend tomcat_server_2
    server tomcat2 10.0.0.2:8080 maxconn 1000

如果您想将www.xyz.com/abc/重定向到abc.xyz.com:

redirect prefix   http://abc.xyz.com if tomcat_path

相关文章

1、安装Apache。 1)执行如下命令,安装Apache服务及其扩展包...
一、先说一下用ansible批量采集机器信息的实现办法: 1、先把...
安装配置 1. 安装vsftpd 检查是否安装了vsftpd # rpm -qa | ...
如何抑制stable_secret读取关键的“net.ipv6.conf.all.stabl...
1 删除0字节文件 find -type f -size 0 -exec rm -rf {} ...
## 步骤 1:安装必要的软件包 首先,需要确保系统已安装 `dh...