1
0
angie-conv-image/image-entry.d/23-http-forward-headers.envsh

57 lines
1.6 KiB
Plaintext
Raw Normal View History

2024-07-31 14:04:15 +03:00
#!/bin/sh
if [ "${NGX_HTTP}" = 0 ] ; then
unset NGX_HTTP_TRANSPARENT_PROXY NGX_HTTP_FAKE_UA NGX_HTTP_X_FORWARDED
else
unset _NGX_HTTP_FAKE_UA _NGX_HTTP_X_FORWARDED
## here should be SANE defaults (!)
_NGX_HTTP_FAKE_UA='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36'
_NGX_HTTP_X_FORWARDED=pass
NGX_HTTP_TRANSPARENT_PROXY=$(gobool_to_int "${NGX_HTTP_TRANSPARENT_PROXY:-0}" 0)
export NGX_HTTP_TRANSPARENT_PROXY
if [ "${NGX_HTTP_TRANSPARENT_PROXY}" = 1 ] ; then
[ -n "${NGX_HTTP_FAKE_UA:-}" ] || NGX_HTTP_FAKE_UA=${_NGX_HTTP_FAKE_UA}
export NGX_HTTP_FAKE_UA
if [ -n "${NGX_HTTP_X_FORWARDED:-}" ] ; then
case "${NGX_HTTP_X_FORWARDED}" in
[Rr][Ee][Mm][Oo][Vv][Ee] ) ;;
* )
log_always "NGX_HTTP_X_FORWARDED: overridden to 'remove' due to NGX_HTTP_TRANSPARENT_PROXY=1"
;;
esac
fi
NGX_HTTP_X_FORWARDED=remove
fi
[ -n "${NGX_HTTP_X_FORWARDED:-}" ] || NGX_HTTP_X_FORWARDED=${_NGX_HTTP_X_FORWARDED}
case "${NGX_HTTP_X_FORWARDED}" in
[Pp][Aa][Ss][Ss] )
## adjust
NGX_HTTP_X_FORWARDED=pass
;;
[Rr][Ee][Mm][Oo][Vv][Ee] )
## adjust
NGX_HTTP_X_FORWARDED=remove
;;
* )
unset x
x=$(gobool_to_int "${NGX_HTTP_X_FORWARDED}")
case "$x" in
0 ) NGX_HTTP_X_FORWARDED=remove ;;
1 ) NGX_HTTP_X_FORWARDED=pass ;;
* )
log_always "NGX_HTTP_X_FORWARDED: unrecognized value: ${NGX_HTTP_X_FORWARDED}"
log_always "setting NGX_HTTP_X_FORWARDED=${_NGX_HTTP_X_FORWARDED}"
NGX_HTTP_X_FORWARDED=${_NGX_HTTP_X_FORWARDED}
;;
esac
unset x
;;
esac
export NGX_HTTP_X_FORWARDED
unset _NGX_HTTP_FAKE_UA _NGX_HTTP_X_FORWARDED
fi