mirror of
https://github.com/fatedier/frp.git
synced 2025-07-27 15:45:39 +00:00
Server Dashboard SSL Support (#2982)
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/pprof"
|
||||
@@ -76,14 +77,21 @@ func (svr *Service) RunDashboardServer(address string) (err error) {
|
||||
ReadTimeout: httpServerReadTimeout,
|
||||
WriteTimeout: httpServerWriteTimeout,
|
||||
}
|
||||
if address == "" || address == ":" {
|
||||
address = ":http"
|
||||
}
|
||||
ln, err := net.Listen("tcp", address)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if svr.cfg.DashboardTLSMode {
|
||||
cert, err := tls.LoadX509KeyPair(svr.cfg.DashboardTLSCertFile, svr.cfg.DashboardTLSKeyFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tlsCfg := &tls.Config{
|
||||
Certificates: []tls.Certificate{cert},
|
||||
}
|
||||
ln = tls.NewListener(ln, tlsCfg)
|
||||
}
|
||||
go server.Serve(ln)
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user