Skip to content

Commit 931f7a8

Browse files
committedMay 8, 2024··
fix: proxy url query unescape issue #377
1 parent d6d7cdb commit 931f7a8

File tree

6 files changed

+18
-13
lines changed

6 files changed

+18
-13
lines changed
 

‎README-es.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Para más información: [debian/conf/nginx.conf](https://salsa.debian.org/nginx-
132132

133133
La UI de Nginx está disponible en las siguientes plataformas:
134134

135-
- Mac OS X 10.10 Yosemite y posterior (amd64 / arm64)
135+
- macOS 11 Big Sur y posterior (amd64 / arm64)
136136
- Linux 2.6.23 and later (x86 / amd64 / arm64 / armv5 / armv6 / armv7)
137137
- Incluyendo pero no limitado a Debian 7 / 8, Ubuntu 12.04 / 14.04 and later, CentOS 6 / 7, Arch Linux
138138
- FreeBSD

‎README-vi_VN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ http {
146146

147147
Giao diện người dùng Nginx có sẵn trên các nền tảng sau:
148148

149-
- Mac OS X 10.10 Yosemite and later (amd64 / arm64)
149+
- macOS 11 Big Sur and later (amd64 / arm64)
150150
- Linux 2.6.23 and later (x86 / amd64 / arm64 / armv5 / armv6 / armv7)
151151
- Bao gồm nhưng không giới hạn Debian 7/8, Ubuntu 12.04/14.04 trở lên, CentOS 6/7, Arch Linux
152152
- FreeBSD

‎README-zh_CN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ http {
125125

126126
Nginx UI 可在以下平台中使用:
127127

128-
- Mac OS X 10.10 Yosemite 及之后版本(amd64 / arm64)
128+
- macOS 11 Big Sur 及之后版本(amd64 / arm64)
129129
- Linux 2.6.23 及之后版本(x86 / amd64 / arm64 / armv5 / armv6 / armv7)
130130
- 包括但不限于 Debian 7 / 8、Ubuntu 12.04 / 14.04 及后续版本、CentOS 6 / 7、Arch Linux
131131
- FreeBSD

‎README-zh_TW.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ http {
128128

129129
Nginx UI 可在以下作業系統中使用:
130130

131-
- Mac OS X 10.10 Yosemite 及之後版本(amd64 / arm64)
131+
- macOS 11 Big Sur 及之後版本(amd64 / arm64)
132132
- Linux 2.6.23 及之後版本(x86 / amd64 / arm64 / armv5 / armv6 / armv7)
133133
- 包括但不限於 Debian 7 / 8、Ubuntu 12.04 / 14.04 及後續版本、CentOS 6 / 7、Arch Linux
134134
- FreeBSD

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ For more information: [debian/conf/nginx.conf](https://salsa.debian.org/nginx-te
140140

141141
Nginx UI is available on the following platforms:
142142

143-
- Mac OS X 10.10 Yosemite and later (amd64 / arm64)
143+
- macOS 11 Big Sur and later (amd64 / arm64)
144144
- Linux 2.6.23 and later (x86 / amd64 / arm64 / armv5 / armv6 / armv7)
145145
- Including but not limited to Debian 7 / 8, Ubuntu 12.04 / 14.04 and later, CentOS 6 / 7, Arch Linux
146146
- FreeBSD

‎router/proxy.go

+13-8
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ func proxy() gin.HandlerFunc {
2727
defer c.Abort()
2828

2929
env := query.Environment
30-
environment, err := env.Where(env.ID.Eq(id)).First()
3130

31+
environment, err := env.Where(env.ID.Eq(id)).First()
3232
if err != nil {
3333
logger.Error(err)
3434
c.AbortWithStatusJSON(http.StatusServiceUnavailable, gin.H{
@@ -37,8 +37,7 @@ func proxy() gin.HandlerFunc {
3737
return
3838
}
3939

40-
u, err := url.JoinPath(environment.URL, c.Request.RequestURI)
41-
40+
baseUrl, err := url.Parse(environment.URL)
4241
if err != nil {
4342
logger.Error(err)
4443
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{
@@ -47,8 +46,7 @@ func proxy() gin.HandlerFunc {
4746
return
4847
}
4948

50-
decodedUri, err := url.QueryUnescape(u)
51-
49+
proxyUrl, err := baseUrl.Parse(c.Request.RequestURI)
5250
if err != nil {
5351
logger.Error(err)
5452
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{
@@ -57,18 +55,25 @@ func proxy() gin.HandlerFunc {
5755
return
5856
}
5957

60-
logger.Debug("Proxy request", decodedUri)
58+
logger.Debug("Proxy request", proxyUrl.String())
6159
client := http.Client{
6260
Transport: &http.Transport{
6361
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
6462
},
6563
}
6664

67-
req, err := http.NewRequest(c.Request.Method, decodedUri, c.Request.Body)
65+
req, err := http.NewRequest(c.Request.Method, proxyUrl.String(), c.Request.Body)
66+
if err != nil {
67+
logger.Error(err)
68+
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{
69+
"message": err.Error(),
70+
})
71+
return
72+
}
73+
6874
req.Header.Set("X-Node-Secret", environment.Token)
6975

7076
resp, err := client.Do(req)
71-
7277
if err != nil {
7378
logger.Error(err)
7479
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{

0 commit comments

Comments
 (0)
Please sign in to comment.