如何解决在HaProxy http请求重定向配置中,卷曲帖子返回了错误的请求
在这里,我试图在HaProxy中重写URL,get方法按预期工作,但我面临POST方法的问题;在下面阐述问题
我正在尝试做什么:
每当有人请求http://preprod.mydomain.com/app_a/ *时,都应该转到>> http://preprod.mydomain.com/something/app_a/*(使用GET方法可以正常工作)
我的HaProxy配置:
acl mydomain_domain hdr(host) -i preprod.mydomain.com
acl app_a_redirection path_beg -i /app_a
http-request set-header X-Location-Path %[capture.req.uri] if app_a_redirection mydomain_domain
http-request replace-header X-Location-Path [^/]+/(.*) \1 if app_a_redirection mydomain_domain
http-request redirect location http://preprod.mydomain.com/something/app_a/%[hdr(X-Location-Path)] code 307 if app_a_redirection mydomain_domain
在POST期间添加错误详细信息:
Request URL:
curl --location --request POST 'https://preprod.mydomain.com/app_a/something-1/something-2' \
--header 'Content-Type: application/json' \
--data-raw '{
"user_id": "xxxxxxxxxxxx","app_id": "xxxxxxxxxxxx","app_version": "1.0.0","client_session_id": "xxxxxxxxxxxx","xpath": "xxxxxxxxxxxx","device_id": "xxxxxxxxxxxx","events": "xxxxxxxxxxxx"
}'
Error: {"timestamp":"2020-08-18T06:57:16.037+0000","status":400,"error":"Bad Request","message":"Required request body is missing: public com.mydomain.something.response.UploadedEventResponse com.mydomain.something.controllers.MobileAppController.postAppEvents(com.mydomain.something.core.models.request.EventsDTO) throws java.lang.Exception","path":"/something/app_a/something-1/something-2"}
解决方法
POST和重定向无法按预期工作。有关流程,请参见Post/Redirect/Get。
好像您要设置路径而不是重定向。
尝试一下,未经测试
http-request set-path http://preprod.mydomain.com/something/app_a/%[hdr(X-Location-Path)] if app_a_redirection mydomain_domain
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。