Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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
1
Merge Requests
1
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
gitlab-ce
Commits
0fa72053
Commit
0fa72053
authored
Dec 10, 2015
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Map all HTTP errors to 502
parent
b0452381
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
2 deletions
+32
-2
main.go
main.go
+4
-2
proxy.go
proxy.go
+28
-0
No files found.
main.go
View file @
0fa72053
...
...
@@ -113,7 +113,8 @@ func main() {
log
.
Fatal
(
err
)
}
var
authTransport
http
.
RoundTripper
// Create Proxy Transport
authTransport
:=
http
.
DefaultTransport
if
*
authSocket
!=
""
{
dialer
:=
&
net
.
Dialer
{
// The values below are taken from http.DefaultTransport
...
...
@@ -126,6 +127,7 @@ func main() {
},
}
}
proxyTransport
:=
&
proxyRoundTripper
{
transport
:
authTransport
}
// The profiler will only be activated by HTTP requests. HTTP
// requests can only reach the profiler if we start a listener. So by
...
...
@@ -137,7 +139,7 @@ func main() {
}()
}
upstream
:=
newUpstream
(
*
authBackend
,
auth
Transport
)
upstream
:=
newUpstream
(
*
authBackend
,
proxy
Transport
)
upstream
.
SetRelativeUrlRoot
(
*
relativeUrlRoot
)
upstream
.
SetProxyTimeout
(
*
proxyTimeout
)
...
...
proxy.go
View file @
0fa72053
package
main
import
(
"bytes"
"io/ioutil"
"net/http"
)
type
proxyRoundTripper
struct
{
transport
http
.
RoundTripper
}
func
(
p
*
proxyRoundTripper
)
RoundTrip
(
r
*
http
.
Request
)
(
res
*
http
.
Response
,
err
error
)
{
res
,
err
=
p
.
transport
.
RoundTrip
(
r
)
// Map error to 502 response
if
err
!=
nil
{
res
=
&
http
.
Response
{
StatusCode
:
502
,
Status
:
err
.
Error
(),
Request
:
r
,
ProtoMajor
:
r
.
ProtoMajor
,
ProtoMinor
:
r
.
ProtoMinor
,
Proto
:
r
.
Proto
,
Header
:
make
(
http
.
Header
),
Trailer
:
make
(
http
.
Header
),
Body
:
ioutil
.
NopCloser
(
&
bytes
.
Buffer
{}),
}
err
=
nil
}
return
}
func
headerClone
(
h
http
.
Header
)
http
.
Header
{
h2
:=
make
(
http
.
Header
,
len
(
h
))
for
k
,
vv
:=
range
h
{
...
...
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