diff --git a/README.md b/README.md index 198c2927233d914554f57971c9a0559c301424ae..8820d3311193696168bba901cf7fc84890f1671e 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,9 @@ A very simple container to redirect HTTP traffic to another server, based on `ng if not set nginx var `$request_uri` is used - `SERVER_REDIRECT_SCHEME` - optionally define scheme to redirect to if not set nginx var `$scheme` is used -- `SERVER_REDIRECT_CODE` - optionally define the http code to use for redirection - if not set nginx 301 - is used +- `SERVER_REDIRECT_CODE` - optionally define the http status code to use for redirection + - if not set or not in list of allowed codes 301 is used as default + - allowed Codes are: 301, 302, 303, 307, 308 See also `docker-compose.yml` file. diff --git a/docker-compose.yml b/docker-compose.yml index 7f5304b2f73c3c307c1b625f22cfcf528e09ac67..31f0501ef998f560804bc5a877e6ac8a2abc5656 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,3 +10,6 @@ to: # optionally define schema to redirect all requests # if not set nginx var $scheme is used #- SERVER_REDIRECT_SCHEME=https + # optionally define the http code to use for redirection + # allowed Codes are: 301, 302, 303, 307, 308, default is 301 + #- SERVER_REDIRECT_CODE=302 diff --git a/run.sh b/run.sh index d06824bda1ab9c46a5e45e041e814152ea5e95f2..a366e5e695a4baeb5a21aa0b09bed600d861f4df 100644 --- a/run.sh +++ b/run.sh @@ -11,9 +11,8 @@ if [ ! -n "$SERVER_NAME" ] ; then fi # set redirect code from optional ENV var -if [ "$SERVER_REDIRECT_CODE" != '302' ] ; then - SERVER_REDIRECT_CODE='301' -fi +# allowed Status Codes are: 301, 302, 303, 307, 308 +expr match "$SERVER_REDIRECT_CODE" '30[12378]$' > /dev/null || SERVER_REDIRECT_CODE='301' # set redirect path from optional ENV var if [ ! -n "$SERVER_REDIRECT_PATH" ] ; then