-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace server redirects Lua impl with NJS impl
- Loading branch information
1 parent
fb4dde4
commit cf12a71
Showing
3 changed files
with
23 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
function srv_redirect(req) { | ||
const redirectTo = req.variables.tmp_redirect_to; | ||
|
||
const requestUri = req.variables.request_uri.replace(/\/$/, ''); | ||
|
||
const useForwardedHeaders = req.variables.forwarded_headers | ||
const xForwardedProto = req.variables.http_x_forwarded_proto; | ||
const xForwardedPort = req.variables.http_x_forwarded_port; | ||
|
||
const redirectScheme = useForwardedHeaders && xForwardedProto ? xForwardedProto : req.variables.scheme; | ||
const redirectPort = useForwardedHeaders && xForwardedPort ? xForwardedPort : req.variables.server_port; | ||
|
||
return `${redirectScheme}://${redirectTo}:${redirectPort}${requestUri}`; | ||
} | ||
|
||
export default { srv_redirect }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters