You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If this is not done then reqURL.Path = "/v1/id/data:abc/def " and reqURLPath.RawPath = "/app/prefix/v1/id/data%3Aabc%2Fdef".
Because of this difference in which RawPath is not rewritten, EscapedPath() (called from url String()) does not return u.RawPath. The function escape(u.Path, encodePath) only escapes ? parameter, and hence req.RequestURI is set to the decoded value, and forwarded upstream.
func (u *URL) EscapedPath() string {
if u.RawPath != "" && validEncoded(u.RawPath, encodePath) {
p, err := unescape(u.RawPath, encodePath)
if err == nil && p == u.Path {
return u.RawPath
}
}
if u.Path == "*" {
return "*" // don't escape (Issue 11202)
}
return escape(u.Path, encodePath)
}
The above fix works fine.
Appreciate if this can be fixed in the next version. Not sure if another flag need to be introduced , or if we could re-use proxyRAWPath for this behavior, or if there is a different way of fixing it.
Your Environment
Version used: v7.4.0 (latest)
The text was updated successfully, but these errors were encountered:
This issue has been inactive for 60 days. If the issue is still relevant please comment to re-activate the issue. If no action is taken within 7 days, the issue will be marked closed.
Upstream is forwarding the decoded url (instead of the original url) while proxying requests
I have the following upstream config:
The following request:
"https://host/app/prefix/v1/id/data%3Aabc%2Fdef "
is decoded to "https://host/v1/id/data:abc/def" , and then forwarded to upstream.
The issue is that "data%3Aabc%2Fdef " is the value of the id. But because it has been decoded, "/" is not interpreted as part of the value.
Expected Behavior
After URL is rewritten based on the upstream rules, the url need to be forwarded to the upstream without decoding the original URL.
Based on the above upstream config, the incoming url "https://host/app/prefix/v1/id/data%3Aabc%2Fdef" should be forwarded to
"https://host/v1/id/data%3Aabc%2Fdef "
Currently, it is decoding, and then forwarding to "https://host/v1/id/data:abc/def "
Possible Solution
Setting "proxyRAWPath" to true in the upstream config did not fix the issue - ( #997)
I had to change the rewrite code logic to also rewrite reqURL.RawPath.
If this is not done then reqURL.Path = "/v1/id/data:abc/def " and reqURLPath.RawPath = "/app/prefix/v1/id/data%3Aabc%2Fdef".
Because of this difference in which RawPath is not rewritten, EscapedPath() (called from url String()) does not return u.RawPath. The function escape(u.Path, encodePath) only escapes ? parameter, and hence req.RequestURI is set to the decoded value, and forwarded upstream.
The above fix works fine.
Appreciate if this can be fixed in the next version. Not sure if another flag need to be introduced , or if we could re-use proxyRAWPath for this behavior, or if there is a different way of fixing it.
Your Environment
The text was updated successfully, but these errors were encountered: