在 HAProxy 中使用路径重写/重定向
Using A Path Rewrite / Redirect In HA Proxy
我正在使用 HA 代理,我有一个路径重定向设置并且有效,路径重定向到 webmin 但它不加载任何 css 并且在提交登录时,它到域而不是应该的路径。
我不确定这是否是 Ha Proxy 问题,也许是 webmin 中的一个配置选项使其从文件夹/路径 运行?
这是我的 Ha Proxy 配置
frontend public
# Listen on ports 80 and 443
bind *:80
# bind *:443 ssl crt /xxxxx
mode http
# Define ACLs for each domain
acl admin url_beg /webmin
#acl admin path_beg -i /webmin
# Figure out which backend (= VM) to use
use_backend webmin if admin
backend webmin
#http-request set-path %[path,regsub(^/webmin/,/)]
#http-request set-path /webmin/%[path]
#http-request replace-uri ([^/:]*://[^/]*)?(.*) /webmin if !remove_webmin
#http-request set-header X-Forwarded-Port %[dst_port]
#http-request add-header X-Forwarded-Proto https if { ssl_fc }
http-request set-header Host xxxx/webmin
#http-response replace-value Location (.*):.* /webmin
#rspadd Strict-Transport-Security:\ max-age=15768000;\ includeSubDomains
#rspadd X-XSS-Protection:\ 1;\ mode=block
http-request set-path %[path,regsub(^/webmin/,/)]
#http-request set-path /webmin/
http-request set-header Host %[src]
http-request set-header X-Forwarded-For %[src]
http-request set-header X-Forwarded-Port %[dst_port]
http-request set-header Connection "keep-alive"
#acl missing_slash path_reg ^/webmin/[^/]*$
#http-request redirect code 301 prefix /webmin drop-query append-slash if missing_slash
#balance leastconn
#option httpclose
#option forwardfor
#cookie JSESSIONID prefix
# Redirect To Webmin
server webadmin 127.0.0.1:10000 check
欢迎任何帮助,
谢谢,
所以我这里有一个可行的解决方案,它不仅与 ha 代理有关,而且您还必须在 webmin 中设置一个前缀路径。
旁注,也许不要使用 'webmin' 作为文件夹/路径重定向。由于 webmin 配置设置似乎使用该路径,因此您最终得到 'webmin/webmin'
高可用性代理配置
frontend public
# Listen on ports 80 and 443
bind *:80
# bind *:443 ssl crt xxxxx
mode http
# Define ACLs for each domain
acl admin url_beg /webmin
#acl app hdr(host) -i xxxxx.com
use_backend webmin if admin
backend webmin
http-request set-header Host DONAME-NAME-HERE/webmin
http-request set-path %[path,regsub(^/webmin/,/)]
http-request set-header X-Forwarded-For %[src]
http-request set-header X-Forwarded-Port %[dst_port]
http-request set-header Connection "keep-alive"
http-response set-header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
http-response set-header X-Frame-Options SAMEORIGIN
http-response set-header X-XSS-Protection "1; mode=block"
balance leastconn
option httpclose
option forwardfor
cookie JSESSIONID prefix
http-response replace-value Location (.*):.* /
# Redirect To Webmin
server webadmin 127.0.0.1:10000 check
Webmin 配置文件
referer=xxxx/webmin/
host=xxx/webmin/
webprefix=/webmin
webprefixnoredir=1
我正在使用 HA 代理,我有一个路径重定向设置并且有效,路径重定向到 webmin 但它不加载任何 css 并且在提交登录时,它到域而不是应该的路径。
我不确定这是否是 Ha Proxy 问题,也许是 webmin 中的一个配置选项使其从文件夹/路径 运行?
这是我的 Ha Proxy 配置
frontend public
# Listen on ports 80 and 443
bind *:80
# bind *:443 ssl crt /xxxxx
mode http
# Define ACLs for each domain
acl admin url_beg /webmin
#acl admin path_beg -i /webmin
# Figure out which backend (= VM) to use
use_backend webmin if admin
backend webmin
#http-request set-path %[path,regsub(^/webmin/,/)]
#http-request set-path /webmin/%[path]
#http-request replace-uri ([^/:]*://[^/]*)?(.*) /webmin if !remove_webmin
#http-request set-header X-Forwarded-Port %[dst_port]
#http-request add-header X-Forwarded-Proto https if { ssl_fc }
http-request set-header Host xxxx/webmin
#http-response replace-value Location (.*):.* /webmin
#rspadd Strict-Transport-Security:\ max-age=15768000;\ includeSubDomains
#rspadd X-XSS-Protection:\ 1;\ mode=block
http-request set-path %[path,regsub(^/webmin/,/)]
#http-request set-path /webmin/
http-request set-header Host %[src]
http-request set-header X-Forwarded-For %[src]
http-request set-header X-Forwarded-Port %[dst_port]
http-request set-header Connection "keep-alive"
#acl missing_slash path_reg ^/webmin/[^/]*$
#http-request redirect code 301 prefix /webmin drop-query append-slash if missing_slash
#balance leastconn
#option httpclose
#option forwardfor
#cookie JSESSIONID prefix
# Redirect To Webmin
server webadmin 127.0.0.1:10000 check
欢迎任何帮助,
谢谢,
所以我这里有一个可行的解决方案,它不仅与 ha 代理有关,而且您还必须在 webmin 中设置一个前缀路径。
旁注,也许不要使用 'webmin' 作为文件夹/路径重定向。由于 webmin 配置设置似乎使用该路径,因此您最终得到 'webmin/webmin'
高可用性代理配置
frontend public
# Listen on ports 80 and 443
bind *:80
# bind *:443 ssl crt xxxxx
mode http
# Define ACLs for each domain
acl admin url_beg /webmin
#acl app hdr(host) -i xxxxx.com
use_backend webmin if admin
backend webmin
http-request set-header Host DONAME-NAME-HERE/webmin
http-request set-path %[path,regsub(^/webmin/,/)]
http-request set-header X-Forwarded-For %[src]
http-request set-header X-Forwarded-Port %[dst_port]
http-request set-header Connection "keep-alive"
http-response set-header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
http-response set-header X-Frame-Options SAMEORIGIN
http-response set-header X-XSS-Protection "1; mode=block"
balance leastconn
option httpclose
option forwardfor
cookie JSESSIONID prefix
http-response replace-value Location (.*):.* /
# Redirect To Webmin
server webadmin 127.0.0.1:10000 check
Webmin 配置文件
referer=xxxx/webmin/
host=xxx/webmin/
webprefix=/webmin
webprefixnoredir=1