mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
Add custom host to reverse proxy core tests
This commit is contained in:
parent
df853e06d7
commit
30d5904067
4 changed files with 15 additions and 1 deletions
|
|
@ -25,6 +25,11 @@ async def headers(request: Request):
|
|||
keepalive = getenv("REVERSE_PROXY_KEEPALIVE", "no") == "yes" or getenv("REVERSE_PROXY_WS", "no") == "yes"
|
||||
request_headers = request.headers
|
||||
http_version = request.scope.get("http_version")
|
||||
|
||||
custom_host = getenv("REVERSE_PROXY_CUSTOM_HOST", "")
|
||||
if custom_host:
|
||||
headers["host"] = custom_host
|
||||
|
||||
print(f"ℹ️ Headers received: {request_headers}", flush=True)
|
||||
|
||||
if keepalive and http_version != "1.1":
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ services:
|
|||
REVERSE_PROXY_AUTH_REQUEST: ""
|
||||
REVERSE_PROXY_AUTH_REQUEST_SIGNIN_URL: ""
|
||||
REVERSE_PROXY_AUTH_REQUEST_SET: ""
|
||||
REVERSE_PROXY_CUSTOM_HOST: ""
|
||||
extra_hosts:
|
||||
- "www.example.com:192.168.0.2"
|
||||
networks:
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ services:
|
|||
REVERSE_PROXY_AUTH_REQUEST: ""
|
||||
REVERSE_PROXY_AUTH_REQUEST_SIGNIN_URL: ""
|
||||
REVERSE_PROXY_AUTH_REQUEST_SET: ""
|
||||
REVERSE_PROXY_CUSTOM_HOST: ""
|
||||
CUSTOM_CONF_SERVER_HTTP_ready: |
|
||||
location /ready {
|
||||
default_type 'text/plain';
|
||||
|
|
@ -74,6 +75,7 @@ services:
|
|||
REVERSE_PROXY_WS: "no"
|
||||
REVERSE_PROXY_KEEPALIVE: "no"
|
||||
REVERSE_PROXY_AUTH_REQUEST: ""
|
||||
REVERSE_PROXY_CUSTOM_HOST: ""
|
||||
networks:
|
||||
bw-services:
|
||||
ipv4_address: 192.168.0.4
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ else
|
|||
echo "REVERSE_PROXY_AUTH_REQUEST=" | sudo tee -a /etc/bunkerweb/variables.env
|
||||
echo "REVERSE_PROXY_AUTH_REQUEST_SIGNIN_URL=" | sudo tee -a /etc/bunkerweb/variables.env
|
||||
echo "REVERSE_PROXY_AUTH_REQUEST_SET=" | sudo tee -a /etc/bunkerweb/variables.env
|
||||
echo "REVERSE_PROXY_CUSTOM_HOST=" | sudo tee -a /etc/bunkerweb/variables.env
|
||||
sudo cp ready.conf /etc/bunkerweb/configs/server-http
|
||||
fi
|
||||
|
||||
|
|
@ -68,8 +69,9 @@ cleanup_stack () {
|
|||
find . -type f -name 'docker-compose.*' -exec sed -i 's@REVERSE_PROXY_AUTH_REQUEST: ".*"@REVERSE_PROXY_AUTH_REQUEST: ""@' {} \;
|
||||
find . -type f -name 'docker-compose.*' -exec sed -i 's@REVERSE_PROXY_AUTH_REQUEST_SIGNIN_URL: ".*"@REVERSE_PROXY_AUTH_REQUEST_SIGNIN_URL: ""@' {} \;
|
||||
find . -type f -name 'docker-compose.*' -exec sed -i 's@REVERSE_PROXY_AUTH_REQUEST_SET: ".*"@REVERSE_PROXY_AUTH_REQUEST_SET: ""@' {} \;
|
||||
find . -type f -name 'docker-compose.*' -exec sed -i 's@REVERSE_PROXY_CUSTOM_HOST: ".*"@REVERSE_PROXY_CUSTOM_HOST: ""@' {} \;
|
||||
else
|
||||
x=12
|
||||
x=13
|
||||
while [ $x -gt 0 ] ; do
|
||||
sudo sed -i '$ d' /etc/bunkerweb/variables.env
|
||||
x=$((x-1))
|
||||
|
|
@ -83,6 +85,7 @@ cleanup_stack () {
|
|||
unset REVERSE_PROXY_AUTH_REQUEST
|
||||
unset REVERSE_PROXY_AUTH_REQUEST_SIGNIN_URL
|
||||
unset REVERSE_PROXY_AUTH_REQUEST_SET
|
||||
unset REVERSE_PROXY_CUSTOM_HOST
|
||||
fi
|
||||
if [[ $end -eq 1 && $exit_code = 0 ]] ; then
|
||||
return
|
||||
|
|
@ -143,6 +146,7 @@ do
|
|||
find . -type f -name 'docker-compose.*' -exec sed -i 's@REVERSE_PROXY_HEADERS: ".*"@REVERSE_PROXY_HEADERS: "Test test;Test2 test2"@' {} \;
|
||||
find . -type f -name 'docker-compose.*' -exec sed -i 's@REVERSE_PROXY_HEADERS_CLIENT: ".*"@REVERSE_PROXY_HEADERS_CLIENT: "Test test;Test2 test2"@' {} \;
|
||||
find . -type f -name 'docker-compose.*' -exec sed -i 's@REVERSE_PROXY_AUTH_REQUEST: ".*"@REVERSE_PROXY_AUTH_REQUEST: "/auth"@' {} \;
|
||||
find . -type f -name 'docker-compose.*' -exec sed -i 's@REVERSE_PROXY_CUSTOM_HOST: ".*"@REVERSE_PROXY_CUSTOM_HOST: "test.example.com"@' {} \;
|
||||
else
|
||||
sudo sed -i 's@REVERSE_PROXY_WS=yes$@REVERSE_PROXY_WS=no@' /etc/bunkerweb/variables.env
|
||||
sudo sed -i 's@REVERSE_PROXY_KEEPALIVE=yes$@REVERSE_PROXY_KEEPALIVE=no@' /etc/bunkerweb/variables.env
|
||||
|
|
@ -150,12 +154,14 @@ do
|
|||
sudo sed -i 's@REVERSE_PROXY_HEADERS=.*$@REVERSE_PROXY_HEADERS=Test test;Test2 test2@' /etc/bunkerweb/variables.env
|
||||
sudo sed -i 's@REVERSE_PROXY_HEADERS_CLIENT=.*$@REVERSE_PROXY_HEADERS_CLIENT=Test test;Test2 test2@' /etc/bunkerweb/variables.env
|
||||
sudo sed -i 's@REVERSE_PROXY_AUTH_REQUEST=.*$@REVERSE_PROXY_AUTH_REQUEST=/auth@' /etc/bunkerweb/variables.env
|
||||
sudo sed -i 's@REVERSE_PROXY_CUSTOM_HOST=.*$@REVERSE_PROXY_CUSTOM_HOST=test.example.com@' /etc/bunkerweb/variables.env
|
||||
unset REVERSE_PROXY_WS
|
||||
unset REVERSE_PROXY_KEEPALIVE
|
||||
export REVERSE_PROXY_INTERCEPT_ERRORS="no"
|
||||
export REVERSE_PROXY_HEADERS="Test test;Test2 test2"
|
||||
export REVERSE_PROXY_HEADERS_CLIENT="Test test;Test2 test2"
|
||||
export REVERSE_PROXY_AUTH_REQUEST="/auth"
|
||||
export REVERSE_PROXY_CUSTOM_HOST="test.example.com"
|
||||
fi
|
||||
elif [ "$test" = "auth_signin" ] ; then
|
||||
echo "↪️ Running tests with reverseproxy activated and auth signin ..."
|
||||
|
|
|
|||
Loading…
Reference in a new issue