feat: add support set http-proxy-redir-url in nginx proxy.

```
location /web/ {
    proxy_set_header HttpProxyRedir http://$server_name;
    proxy_pass http://127.0.0.1:5913;
}
```

Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
This commit is contained in:
Jianhui Zhao
2025-01-14 12:03:55 +08:00
parent 626ee13729
commit a749bd3e8a
3 changed files with 71 additions and 1 deletions
+27
View File
@@ -132,6 +132,33 @@ server {
}
```
The parameter 'http-proxy-redir-url' in rttys.conf can also be configured
by setting a new HTTP header 'HttpProxyRedir' in nginx.
```
server {
listen 80;
server_name rtty.your-server.com;
location /connect/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass http://127.0.0.1:5913;
}
location /web/ {
proxy_set_header HttpProxyRedir http://$server_name;
proxy_pass http://127.0.0.1:5913;
}
location / {
proxy_pass http://127.0.0.1:5913;
}
}
```
## Docker
### Simple run
+40
View File
@@ -130,6 +130,46 @@ server {
}
```
在 rttys.conf 中的参数 http-proxy-redir-url 也可以通过在 nginx 中设置一个新
的 HTTP header HttpProxyRedir 来配置.
```
server {
listen 80;
server_name rtty.your-server.com;
location /connect/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass http://127.0.0.1:5913;
}
location /web/ {
proxy_set_header HttpProxyRedir http://$server_name;
proxy_pass http://127.0.0.1:5913;
}
location / {
proxy_pass http://127.0.0.1:5913;
}
}
server {
listen 80;
server_name web.your-server.com;
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass http://127.0.0.1:5914;
}
}
```
## Docker
sudo docker run -it -p 5912:5912 -p 5913:5913 -p 5914:5914 zhaojh329/rttys:latest \
+4 -1
View File
@@ -307,7 +307,10 @@ func httpProxyRedirect(br *broker, c *gin.Context) {
return
}
location := cfg.HttpProxyRedirURL
location := c.Request.Header.Get("HttpProxyRedir")
if location == "" {
location = cfg.HttpProxyRedirURL
}
if location == "" {
host, _, err := net.SplitHostPort(c.Request.Host)