HAProxy path_beg not redirecting

眉间皱痕 提交于 2019-12-08 04:09:00

问题


I'm testing a simple haproxy rule to make http://localhost/haproxy-dconv take me to http://cbonte.github.io/haproxy-dconv but it isn't working. 404 response seems to be from the site but the path isn't resolving.

frontend HTTP
  mode http
  bind *:80

  acl url_dconv path_beg /haproxy-dconv
  use_backend dconv-backend if url_dconv

backend dconv-backend
  mode http
  server dconv cbonte.github.io

回答1:


Try this -

frontend HTTP
    mode http
    bind *:80
    use_backend dconv-backend if { path_beg /haproxy-dconv/ }

backend dconv-backend
    mode http
    server dconv cbonte.github.io

Source: https://cbonte.github.io/haproxy-dconv/1.7/configuration.html#use_backend




回答2:


That is because the Host header that is being sent is localhost, instead of cbonte.github.io. Add this to your backend:

http-request set-header Host cbonte.github.io

Also note that without the ending slash, you will get a 301, so make sure you send http://localhost/cbonte-dconv/ and fix your ACL.



来源:https://stackoverflow.com/questions/43081363/haproxy-path-beg-not-redirecting

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!