diff --git a/README.md b/README.md index 9be4b75..99f6108 100644 --- a/README.md +++ b/README.md @@ -504,6 +504,14 @@ Context : *global*, *multisite* Only valid when `USE_REVERSE_PROXY` is set to *yes*. Set it to *yes* when the corresponding `REVERSE_PROXY_HOST` is a WebSocket server. You can set multiple url/host by adding a suffix number to the variable name like this : `REVERSE_PROXY_WS_1`, `REVERSE_PROXY_WS_2`, `REVERSE_PROXY_WS_3`, ... +`REVERSE_PROXY_HEADERS` +Values : *\* +Examples : Access-Control-Allow-Origin 'https://mydomain.dev'; Custom_Api_Header 'test'; +Default value : "" +Context : *global*, *multisite* +Only valid when `USE_REVERSE_PROXY` is set to *yes*. Set it to *yes* when the corresponding `REVERSE_PROXY_HOST` is a WebSocket server. +You can set multiple url/host by adding a suffix number to the variable name like this : `REVERSE_PROXY_HEADERS_1`, `REVERSE_PROXY_HEADERS_2`, `REVERSE_PROXY_HEADERS_3`, ... + `PROXY_REAL_IP` Values : *yes* | *no* Default value : *no* diff --git a/confs/site/reverse-proxy.conf b/confs/site/reverse-proxy.conf index 89cbc6e..1fb489b 100644 --- a/confs/site/reverse-proxy.conf +++ b/confs/site/reverse-proxy.conf @@ -2,4 +2,5 @@ location %REVERSE_PROXY_URL% { proxy_pass %REVERSE_PROXY_HOST%; %REVERSE_PROXY_HEADERS% %REVERSE_PROXY_WS% + %REVERSE_PROXY_CUSTOM_HEADERS% } diff --git a/entrypoint/site-config.sh b/entrypoint/site-config.sh index a0f078c..43e8809 100644 --- a/entrypoint/site-config.sh +++ b/entrypoint/site-config.sh @@ -68,11 +68,19 @@ if [ "$USE_REVERSE_PROXY" = "yes" ] ; then value=$(echo "$var" | sed "s/${name}=//") host=$(echo "$name" | sed "s/URL/HOST/") host_value=$(env | grep "^${host}=" | sed "s/${host}=//") + custom_headers=$(echo "$name" | sed "s/URL/HEADERS/") + custom_headers_value=$(env | grep "^${host}=" | sed "s/${host}=//") ws=$(echo "$name" | sed "s/URL/WS/") ws_value=$(env | grep "^${ws}=" | sed "s/${ws}=//") cp "${NGINX_PREFIX}reverse-proxy.conf" "${NGINX_PREFIX}reverse-proxy-${i}.conf" replace_in_file "${NGINX_PREFIX}reverse-proxy-${i}.conf" "%REVERSE_PROXY_URL%" "$value" replace_in_file "${NGINX_PREFIX}reverse-proxy-${i}.conf" "%REVERSE_PROXY_HOST%" "$host_value" + if [ "$custom_headers_value" != "" ] ; then + IFS=';' ;for header_value in $(echo "$custom_headers_value") ; do + replace_in_file "${NGINX_PREFIX}reverse-proxy-${i}.conf" "%REVERSE_PROXY_CUSTOM_HEADERS%" "more_set_headers $header_value;\n%REVERSE_PROXY_CUSTOM_HEADERS%" + done + replace_in_file "${NGINX_PREFIX}reverse-proxy-${i}.conf" "%REVERSE_PROXY_CUSTOM_HEADERS%" "" + fi replace_in_file "${NGINX_PREFIX}reverse-proxy-${i}.conf" "%REVERSE_PROXY_HEADERS%" "include ${NGINX_PREFIX}reverse-proxy-headers.conf;" if [ "$ws_value" = "yes" ] ; then replace_in_file "${NGINX_PREFIX}reverse-proxy-${i}.conf" "%REVERSE_PROXY_WS%" "proxy_http_version 1.1;\nproxy_set_header Upgrade \$http_upgrade;\nproxy_set_header Connection \"Upgrade\";\n"