mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-04-30 15:26:24 +02:00
include referer header in remote requests
this is an optional feature which is disabled by default, since it is only needed in a few select cases and risks accidentally exposing internal URLs. Fixes #216
This commit is contained in:
parent
edd9dbac2d
commit
8c28dca762
3 changed files with 12 additions and 0 deletions
|
|
@ -56,6 +56,10 @@ type Proxy struct {
|
|||
// hosts are allowed.
|
||||
Referrers []string
|
||||
|
||||
// IncludeReferer controls whether the original Referer request header
|
||||
// is included in remote requests.
|
||||
IncludeReferer bool
|
||||
|
||||
// DefaultBaseURL is the URL that relative remote URLs are resolved in
|
||||
// reference to. If nil, all remote URLs specified in requests must be
|
||||
// absolute.
|
||||
|
|
@ -166,6 +170,10 @@ func (p *Proxy) serveImage(w http.ResponseWriter, r *http.Request) {
|
|||
if len(p.ContentTypes) != 0 {
|
||||
actualReq.Header.Set("Accept", strings.Join(p.ContentTypes, ", "))
|
||||
}
|
||||
if p.IncludeReferer {
|
||||
// pass along the referer header from the original request
|
||||
copyHeader(actualReq.Header, r.Header, "referer")
|
||||
}
|
||||
resp, err := p.Client.Do(actualReq)
|
||||
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue