Docker
HAproxy 配置 - Docker 中的 Wordpress + phpMyAdmin + mariadb
N00b 在這裡,我正在嘗試為 HAproxy 創建一個配置文件,但我對這個主題有一些理解問題。
因此,對於此範例,我希望能夠在訪問http://VMip>以及使用<http://VMip/phpmyadmin時能夠載入 wordpress,以便能夠使用 phpMyAdmin 創建數據庫/使用者等。
下面是我的 HAproxy 配置文件。
如果您需要更多資訊,我會很樂意提供。先感謝您。
global log fd@2 local2 chroot /var/lib/haproxy pidfile /var/run/haproxy.pid maxconn 4000 stats socket /var/lib/haproxy/stats expose-fd listeners master-worker resolvers docker nameserver dns1 127.0.0.11:53 resolve_retries 3 timeout resolve 1s timeout retry 1s hold other 10s hold refused 10s hold nx 10s hold timeout 10s hold valid 10s hold obsolete 10s defaults timeout connect 10s timeout client 30s timeout server 30s log global mode http option httplog frontend www bind *:80 use_backend stat if { path -i /my-stats } use_backend php if { path -i /phpmyadmin } default_backend wordpress backend php # reqrep ^([^\ :])\ /phpmyadmin/(.) \1\ /\2 balance roundrobin server php phpmyadmin:80 check resolvers docker init-addr libc,none backend wordpress balance roundrobin server wordpress wordp:80 check resolvers docker init-addr libc,none backend stat stats enable stats uri /my-stats stats refresh 15s stats show-legends stats show-node
該解決方案在文件 https://docs.phpmyadmin.net/en/latest/setup.html中找到,並應用於以下配置,該配置按預期工作:
global log fd@2 local2 chroot /var/lib/haproxy pidfile /var/run/haproxy.pid maxconn 4000 stats socket /var/lib/haproxy/stats expose-fd listeners master-worker resolvers docker nameserver dns1 127.0.0.11:53 resolve_retries 3 timeout resolve 1s timeout retry 1s hold other 10s hold refused 10s hold nx 10s hold timeout 10s hold valid 10s hold obsolete 10s defaults timeout connect 10s timeout client 30s timeout server 30s log global mode http option httplog frontend http bind *:80 use_backend stat if { path -i /my-stats } option forwardfor option http-server-close acl phpmyadmin path_dir /phpmyadmin use_backend php if phpmyadmin default_backend wordpress backend php mode http balance source hash-type consistent reqirep ^(GET|POST|HEAD)\ /phpmyadmin/(.*) \1\ /\2 acl hdr_location res.hdr(Location) -m found rspirep ^Location:\ (http?://phpmyadmin.local(:[0-9]+)?)?(/.*) Location:\ // if hdr_location server-template php- 7 phpmyadmin:80 cookie php check resolvers docker init-addr libc,none backend wordpress balance source hash-type consistent server-template wordp- 7 wordp:80 cookie wordpress check resolvers docker init-addr libc,none backend stat stats enable stats uri /my-stats stats refresh 15s stats show-legends stats show-node