Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
autoradio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ale
autoradio
Commits
d11a3578
Commit
d11a3578
authored
9 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
protect access to /debug/
parent
fde7a161
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fe/http.go
+26
-7
26 additions, 7 deletions
fe/http.go
with
26 additions
and
7 deletions
fe/http.go
+
26
−
7
View file @
d11a3578
...
...
@@ -27,6 +27,9 @@ import (
var
(
proxyStreams
=
flag
.
Bool
(
"enable-icecast-proxy"
,
false
,
"Proxy the local icecast"
)
disableDebug
=
flag
.
Bool
(
"disable-debug"
,
false
,
"Disable /debug/ URLs"
)
restrictDebug
=
flag
.
Bool
(
"restrict-debug"
,
true
,
"Restrict access to /debug/ URLs to localhost"
)
httpStatusCodes
=
instrumentation
.
NewCounter
(
"http.status"
)
httpTargetStats
=
instrumentation
.
NewCounter
(
"http.target"
)
sourceConnections
=
instrumentation
.
NewCounter
(
"http.source_connections"
)
...
...
@@ -366,6 +369,16 @@ func (h *HttpRedirector) serveStatusPage(w http.ResponseWriter, r *http.Request)
w
.
Write
(
buf
.
Bytes
())
}
func
withLocalhost
(
h
http
.
Handler
)
http
.
Handler
{
return
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
if
ip
:=
net
.
ParseIP
(
r
.
RemoteAddr
);
!
ip
.
IsLoopback
()
{
http
.
Error
(
w
,
"Unauthorized"
,
http
.
StatusUnauthorized
)
return
}
h
.
ServeHTTP
(
w
,
r
)
})
}
func
(
h
*
HttpRedirector
)
createHandler
()
http
.
Handler
{
// Create our HTTP handler stack.
mux
:=
http
.
NewServeMux
()
...
...
@@ -379,13 +392,19 @@ func (h *HttpRedirector) createHandler() http.Handler {
http
.
FileServer
(
http
.
Dir
(
h
.
staticDir
))),
nil
))
// Pass /debug/ to the default ServeMux, all the default debug
// handlers are installed there. Add a debug handler for the
// LoadBalancer data. Gzip the responses.
debugMux
:=
http
.
NewServeMux
()
debugMux
.
Handle
(
"/debug/lbv2"
,
h
.
lb
)
debugMux
.
Handle
(
"/"
,
http
.
DefaultServeMux
)
mux
.
Handle
(
"/debug/"
,
handlers
.
GZIPHandler
(
debugMux
,
nil
))
if
!*
disableDebug
{
// Pass /debug/ to the default ServeMux, all the default debug
// handlers are installed there. Add a debug handler for the
// LoadBalancer data. Gzip the responses.
debugMux
:=
http
.
NewServeMux
()
debugMux
.
Handle
(
"/debug/lbv2"
,
h
.
lb
)
debugMux
.
Handle
(
"/"
,
http
.
DefaultServeMux
)
var
h
http
.
Handler
=
handlers
.
GZIPHandler
(
debugMux
,
nil
)
if
*
restrictDebug
{
h
=
withLocalhost
(
h
)
}
mux
.
Handle
(
"/debug/"
,
h
)
}
// Optionally enable a reverse proxy to the local Icecast for
// the direct stream URLs (below IcecastMountPrefix).
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment