make request logging info level, add request logging to webserver, update service file

This commit is contained in:
Cyberes 2024-04-12 19:31:28 -06:00
parent 684d9c8adf
commit 8cddcbcb2c
3 changed files with 6 additions and 3 deletions

View File

@ -6,7 +6,7 @@ After=network.target
SyslogIdentifier=proxy-loadbalancer
User=loadbalancer
Group=loadbalancer
ExecStart=/srv/loadbalancer/proxy-loadbalancer --config /etc/proxy-loadbalancer/config.yml
ExecStart=/srv/loadbalancer/proxy-loadbalancer -d --config /etc/proxy-loadbalancer/config.yml
Restart=always
[Install]

View File

@ -79,7 +79,7 @@ func (p *ForwardProxyCluster) proxyHttpConnect(w http.ResponseWriter, req *http.
log.Debugf(`%s -> %s -- HTTP -- Rejecting request: "%s"`, remoteAddr, proxyHost, err)
return
}
defer log.Debugf(`%s -> %s -> %s -- HTTP`, remoteAddr, proxyHost, req.Host)
defer log.Infof(`%s -> %s -> %s -- HTTP`, remoteAddr, proxyHost, req.Host)
parsedProxyUrl.Scheme = "http"
if proxyUser != "" && proxyPass != "" {
@ -124,7 +124,7 @@ func (p *ForwardProxyCluster) proxyHttpsConnect(w http.ResponseWriter, req *http
log.Debugf(`%s -> %s -- CONNECT -- Rejecting request: "%s"`, remoteAddr, proxyHost, err)
return
}
defer log.Debugf(`%s -> %s -> %s -- CONNECT`, remoteAddr, proxyHost, targetHost)
defer log.Infof(`%s -> %s -> %s -- CONNECT`, remoteAddr, proxyHost, targetHost)
// Connect to the downstream proxy server instead of the target host
proxyConn, err := net.DialTimeout("tcp", proxyHost, config.GetConfig().ProxyConnectTimeout)

View File

@ -5,6 +5,7 @@ import (
"fmt"
"math"
"math/rand"
"net"
"net/http"
"net/url"
"time"
@ -24,6 +25,8 @@ func (p *ForwardProxyCluster) ServeHTTP(w http.ResponseWriter, req *http.Request
// HTTP
if req.URL.Scheme == "" {
// When the client connects using the server as a web server.
remoteAddr, _, _ := net.SplitHostPort(req.RemoteAddr)
defer log.Infof(`%s -- %s`, remoteAddr, req.URL.Path)
if req.URL.Path == "/" {
rand.New(rand.NewSource(time.Now().Unix()))
fmt.Fprint(w, "proxy-loadbalancer <https://git.evulid.cc/cyberes/proxy-loadbalancer>\nSee /json for status info.\n\n\n\n"+retardation[rand.Intn(len(retardation))])