mirror of
https://github.com/zhaojh329/rttys.git
synced 2026-02-27 09:53:21 +08:00
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:
@@ -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
|
||||
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user