Skip to content

Commit

Permalink
feat: add support set http-proxy-redir-domain in nginx proxy.
Browse files Browse the repository at this point in the history
```
location /web/ {
    proxy_set_header HttpProxyRedir http://web.your-server.com;
    proxy_set_header HttpProxyRedirDomain .your-server.com
    proxy_pass http://127.0.0.1:5913;
}
```

Signed-off-by: Jianhui Zhao <[email protected]>
  • Loading branch information
zhaojh329 committed Jan 16, 2025
1 parent 282f445 commit 5e8bb12
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ server {
}
```

The parameter 'http-proxy-redir-url' in rttys.conf can also be configured
by setting a new HTTP header 'HttpProxyRedir' in nginx.
The parameter 'http-proxy-redir-url' and 'http-proxy-redir-domain' in rttys.conf can also be configured
by setting new HTTP headers in nginx.

```
server {
Expand All @@ -150,6 +150,7 @@ server {
location /web/ {
proxy_set_header HttpProxyRedir http://web.your-server.com;
proxy_set_header HttpProxyRedirDomain .your-server.com
proxy_pass http://127.0.0.1:5913;
}
Expand Down
5 changes: 3 additions & 2 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ server {
}
```

在 rttys.conf 中的参数 http-proxy-redir-url 也可以通过在 nginx 中设置一个新
的 HTTP header HttpProxyRedir 来配置.
在 rttys.conf 中的参数 http-proxy-redir-url 和 http-proxy-redir-domain 也可以通过在 nginx 中设置新
的 HTTP headers 来配置.

```
server {
Expand All @@ -148,6 +148,7 @@ server {
location /web/ {
proxy_set_header HttpProxyRedir http://web.your-server.com;
proxy_set_header HttpProxyRedirDomain .your-server.com
proxy_pass http://127.0.0.1:5913;
}
Expand Down
12 changes: 9 additions & 3 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,15 @@ func httpProxyRedirect(br *broker, c *gin.Context) {

httpProxySessions.Store(sid, make(chan struct{}))

domain := cfg.HttpProxyRedirDomain

log.Debug().Msgf("set cookie domain: %s", domain)
domain := c.Request.Header.Get("HttpProxyRedirDomain")
if domain == "" {
domain = cfg.HttpProxyRedirDomain
if domain != "" {
log.Debug().Msgf("set cookie domain from config: %s", domain)
}
} else {
log.Debug().Msgf("set cookie domain from HTTP header: %s", domain)
}

c.SetCookie("rtty-http-sid", sid, 0, "", domain, false, true)
c.SetCookie("rtty-http-devid", devid, 0, "", domain, false, true)
Expand Down

0 comments on commit 5e8bb12

Please sign in to comment.