vhost: add real ip in first request of one connection

1. fix #248 host_header_rewrite bug
2. close #270, #127
This commit is contained in:
fatedier
2017-07-01 01:54:37 +08:00
parent b55a24a27e
commit 4cc1663a5f
2 changed files with 31 additions and 17 deletions

View File

@@ -182,9 +182,10 @@ func (l *Listener) Accept() (frpNet.Conn, error) {
return nil, fmt.Errorf("Listener closed")
}
// if rewriteFunc is exist and rewriteHost is set
// if rewriteFunc is exist
// rewrite http requests with a modified host header
if l.mux.rewriteFunc != nil && l.rewriteHost != "" {
// if l.rewriteHost is empty, nothing to do
if l.mux.rewriteFunc != nil {
sConn, err := l.mux.rewriteFunc(conn, l.rewriteHost)
if err != nil {
l.Warn("host header rewrite failed: %v", err)