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

60 lines
1.6 KiB
Plaintext
Raw Permalink Normal View History

2024-09-17 14:11:00 +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/128.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
2024-09-30 20:45:03 +03:00
if [ -z "${NGX_HTTP_X_FORWARDED:-}" ] ; then
NGX_HTTP_X_FORWARDED=${_NGX_HTTP_X_FORWARDED}
else
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
;;
2024-09-17 14:11:00 +03:00
* )
2024-09-30 20:45:03 +03:00
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
2024-09-17 14:11:00 +03:00
;;
esac
2024-09-30 20:45:03 +03:00
fi
2024-09-17 14:11:00 +03:00
export NGX_HTTP_X_FORWARDED
unset _NGX_HTTP_FAKE_UA _NGX_HTTP_X_FORWARDED
fi