Skip to content

Commit

Permalink
avoid dead loop of forwardings
Browse files Browse the repository at this point in the history
  • Loading branch information
netptop committed Mar 11, 2020
1 parent c32dfbf commit ffcb3b5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,10 @@ let Proxy = ({urlModify, httpprefix, serverName, port, cookieDomainRewrite, loca
let myRe = new RegExp(`/${httpprefix}/${serverName}.*?/`, 'g') // match group
req.url = req.url.replace(myRe, '/')

let fwdStr = req.headers['X-Forwarded-For'] || req.headers['x-forwarded-for']

let {host, httpType} = getHostFromReq(req)
if (host == '' || host.indexOf('.') === -1) {
if (host == '' || host.indexOf('.') === -1 || (fwdStr && fwdStr.split(',').length > 3)) { // too many forwardings
res.status(404).send("{}")
return
}
Expand Down

0 comments on commit ffcb3b5

Please sign in to comment.