Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
2d6ff406
Commit
2d6ff406
authored
May 29, 2015
by
Austin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add supported for ws in reverse proxy
parent
9bdd9bde
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
3 deletions
+35
-3
config/setup/rewrite_test.go
config/setup/rewrite_test.go
+2
-1
middleware/proxy/reverseproxy.go
middleware/proxy/reverseproxy.go
+33
-2
No files found.
config/setup/rewrite_test.go
View file @
2d6ff406
...
...
@@ -4,8 +4,9 @@ import (
"testing"
"fmt"
"github.com/mholt/caddy/middleware/rewrite"
"regexp"
"github.com/mholt/caddy/middleware/rewrite"
)
func
TestRewrite
(
t
*
testing
.
T
)
{
...
...
middleware/proxy/reverseproxy.go
View file @
2d6ff406
...
...
@@ -16,6 +16,8 @@ import (
"time"
)
const
HTTPSwitchProtocols
=
101
// onExitFlushLoop is a callback set by tests to detect the state of the
// flushLoop() goroutine.
var
onExitFlushLoop
func
()
...
...
@@ -153,8 +155,37 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request, extr
copyHeader
(
rw
.
Header
(),
res
.
Header
)
if
res
.
StatusCode
==
HTTPSwitchProtocols
{
hj
,
ok
:=
rw
.
(
http
.
Hijacker
)
if
!
ok
{
return
nil
}
conn
,
_
,
err
:=
hj
.
Hijack
()
if
err
!=
nil
{
return
err
}
backendConn
,
err
:=
net
.
Dial
(
"tcp"
,
outreq
.
Host
)
if
err
!=
nil
{
conn
.
Close
()
return
err
}
outreq
.
Write
(
backendConn
)
go
func
()
{
io
.
Copy
(
backendConn
,
conn
)
// write tcp stream to backend.
backendConn
.
Close
()
}()
io
.
Copy
(
conn
,
backendConn
)
// read tcp stream from backend.
conn
.
Close
()
}
else
{
rw
.
WriteHeader
(
res
.
StatusCode
)
p
.
copyResponse
(
rw
,
res
.
Body
)
}
return
nil
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment