HAProxy背后的Apache mod_proxy

时间:2019-05-17 02:46:35

标签: haproxy mod-proxy

我的任务是在HAProxy后面运行Apache mod_proxy。当前,它以最简单的方式进行配置。我的问题是,需要在Apache mod_proxy中访问的链接是“ http://xxx.xxx.xxx.xx/test”,我不知道如何使用HAProxy进行访问。

我的其他想法是在Apache mod_proxy中将“ /”重定向到“ / test”,但是我不确定它是否正确。

这是我在haproxy.cfg中的配置

[root@HAProxy haproxy]# cat haproxy.cfg
global
   log /dev/log local0
   log /dev/log local1 notice
   chroot /var/lib/haproxy
   stats timeout 30s
   user haproxy
   group haproxy
   daemon

defaults
   log global
   mode http
   option httplog
   option dontlognull
   timeout connect 5000
   timeout client 50000
   timeout server 50000

frontend http_front
   bind *:80
   stats uri /haproxy?stats
   default_backend http_back

backend http_back
   balance roundrobin
   server Apache 192.168.122.103:80/ check

这是我在Apache mod_proxy中的当前配置

[root@Apache conf.d]# cat port8080.conf
<VirtualHost *:80>

    DocumentRoot "/var/www/html"
    DirectoryIndex index.html index. cgi index.php index.shtml

    <Proxy "balancer://apache_mod_proxy">
            BalancerMember "http://192.168.122.125:8080"
    </Proxy>

    ProxyPreserveHost On
    ProxyPass "/auth/" "balancer://apache_mod_proxy/auth/"
    ProxyPassReverse "/auth/" "balancer://apache_mod_proxy/auth/"

    OIDCProviderMetadataURL "http://192.168.122.103/auth/realms/ci/.well-known/openid-configuration"
    OIDCClientID "apache24"
    OIDCClientName "apache24"
    OIDCClientSecret "cc251291-9254-42ef-8073-6f5b396f73cc"
    OIDCScope "openid email profile"
    OIDCProviderTokenEndPointAuth "client_secret_basic"

    OIDCRedirectURI http://192.168.122.103/test/redirect_uri
    OIDCCryptoPassphrase 0123456789
    OIDCRemoteUserClaim "preferred_username"

    <Location /test>
       AuthType openid-connect
       Require valid-user
    </Location>

我期望的是,当我访问HAproxy“ http://192.168.122.182/”时,我想看到的显示是“ http://192.168.122.103/test”的内容<-apache mod_proxy

**更新 我尝试添加“重定向”

    frontend http_front
        bind *:80
        stats uri /haproxy?stats
        acl path_root path /
        redirect location http://192.168.122.103/test/ if path_root
        default_backend http_back

但是它现在正在直接与后端通信,而不是通过HAProxy

0 个答案:

没有答案