mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-22 06:55:20 +00:00
Merge branch 'feature/ssl-support-for-websockets' of https://github.com/mattbaird/cmd into mattbaird-feature/ssl-support-for-websockets
This commit is contained in:
@@ -204,7 +204,15 @@ func getFreePort() (port int) {
|
|||||||
// proxyWebsocket copies data between websocket client and server until one side
|
// proxyWebsocket copies data between websocket client and server until one side
|
||||||
// closes the connection. (ReverseProxy doesn't work with websocket requests.)
|
// closes the connection. (ReverseProxy doesn't work with websocket requests.)
|
||||||
func proxyWebsocket(w http.ResponseWriter, r *http.Request, host string) {
|
func proxyWebsocket(w http.ResponseWriter, r *http.Request, host string) {
|
||||||
d, err := net.Dial("tcp", host)
|
var d net.Conn
|
||||||
|
var err error
|
||||||
|
if revel.HttpSsl {
|
||||||
|
// since this proxy isn't used in production, it's OK to set InsecureSkipVerify to true
|
||||||
|
// no need to add another configuration option.
|
||||||
|
d, err = tls.Dial("tcp", host, &tls.Config{InsecureSkipVerify: true})
|
||||||
|
} else {
|
||||||
|
d, err = net.Dial("tcp", host)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, "Error contacting backend server.", 500)
|
http.Error(w, "Error contacting backend server.", 500)
|
||||||
revel.ERROR.Printf("Error dialing websocket backend %s: %v", host, err)
|
revel.ERROR.Printf("Error dialing websocket backend %s: %v", host, err)
|
||||||
|
|||||||
Reference in New Issue
Block a user