mirror of
https://github.com/zhaojh329/rttys.git
synced 2026-02-27 09:53:21 +08:00
Remove built-in TLS support in favor of Nginx termination
This commit eliminates the native TLS implementation from rttys. Going forward, TLS termination will be handled exclusively by Nginx reverse proxy. Key changes include: 1. Removed all TLS-related configuration options 2. Deleted certificate handling and encryption logic 3. Simplified network stack to plain TCP only 4. Updated documentation to reflect new architecture Rationale: - Delegates TLS to specialized reverse proxy (Nginx) - Improves security through separation of concerns - Reduces attack surface of rttys core service - Enables centralized certificate management - Facilitates future scalability with proxy layer Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
This commit is contained in:
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"crypto/tls"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -244,24 +243,9 @@ func listenHttpProxy(brk *broker) {
|
||||
log.Fatal().Msg(err.Error())
|
||||
}
|
||||
|
||||
if cfg.WebUISslCert != "" && cfg.WebUISslKey != "" {
|
||||
crt, err := tls.LoadX509KeyPair(cfg.WebUISslCert, cfg.WebUISslKey)
|
||||
if err != nil {
|
||||
log.Fatal().Msg(err.Error())
|
||||
}
|
||||
|
||||
tlsConfig := &tls.Config{Certificates: []tls.Certificate{crt}}
|
||||
|
||||
ln = tls.NewListener(ln, tlsConfig)
|
||||
}
|
||||
|
||||
cfg.HttpProxyPort = ln.Addr().(*net.TCPAddr).Port
|
||||
|
||||
if cfg.WebUISslCert != "" && cfg.WebUISslKey != "" {
|
||||
log.Info().Msgf("Listen http proxy on: %s SSL on", ln.Addr().(*net.TCPAddr))
|
||||
} else {
|
||||
log.Info().Msgf("Listen http proxy on: %s SSL off", ln.Addr().(*net.TCPAddr))
|
||||
}
|
||||
log.Info().Msgf("Listen http proxy on: %s", ln.Addr().(*net.TCPAddr))
|
||||
|
||||
go func() {
|
||||
defer ln.Close()
|
||||
@@ -344,11 +328,7 @@ func httpProxyRedirect(br *broker, c *gin.Context) {
|
||||
host = c.Request.Host
|
||||
}
|
||||
|
||||
if cfg.WebUISslCert != "" && cfg.WebUISslKey != "" {
|
||||
location = "https://" + host
|
||||
} else {
|
||||
location = "http://" + host
|
||||
}
|
||||
location = "http://" + host
|
||||
|
||||
if cfg.HttpProxyPort != 80 {
|
||||
location += fmt.Sprintf(":%d", cfg.HttpProxyPort)
|
||||
|
||||
Reference in New Issue
Block a user