diff --git a/.github/workflows/cache-control.yml b/.github/workflows/cache-control.yml index 0422e5f9c30..423a5c5bb56 100644 --- a/.github/workflows/cache-control.yml +++ b/.github/workflows/cache-control.yml @@ -56,78 +56,75 @@ jobs: - name: Run Docker containers and script run: | docker network create onlyoffice - docker-compose -f install/docker/proxy.yml up -d - docker-compose -f install/docker/router.yml up -d + docker-compose -f install/docker/proxy.yml -f install/docker/router.yml up -d - name: Wait for containers to become ready run: | - echo "Waiting for containers to become ready..." - bash -c 'until curl -s http://localhost:80; do sleep 1; done' - bash -c 'until curl -s http://localhost:8092; do sleep 1; done' + timeout 30 bash -c 'until curl -s http://localhost:80; do sleep 1; done' + timeout 30 bash -c 'until curl -s http://localhost:8092; do sleep 1; done' - name: Execute testing script run: | - CACHE_CONTROLS=( - "no-cache" - "no-store" - "public" - "private" - "max-age=0" - "max-age=60" - "s-maxage=60" - "max-age=3600" - "must-revalidate" - "proxy-revalidate" - "max-age=120,must-revalidate" - "no-cache,no-store" - "public,max-age=60" - "private,max-age=120" - "immutable" - "public,s-maxage=60,max-age=30" - "no-cache,max-age=0" - "private,no-cache" - "public,no-transform" + CACHE_CONTROLS_HITS=( + "max-age=60" + "s-maxage=60" + "max-age=3600" + "max-age=120,must-revalidate" + "public,max-age=60" + "immutable" + "public,s-maxage=60,max-age=30" + "immutable,max-age=3600" + "max-age=300,must-revalidate" + "proxy-revalidate,max-age=600" + "no-transform,max-age=900" + "must-revalidate,max-age=1200" + "proxy-revalidate,s-maxage=150" + "public,immutable,max-age=31536000" + "public,max-age=120,proxy-revalidate" + "public,no-transform,s-maxage=60,max-age=30" + "max-age=60,no-transform,must-revalidate" + ) + CACHE_CONTROLS_MISSES=( + "no-cache" + "no-store" + "public" + "private" + "max-age=0" + "must-revalidate" + "proxy-revalidate" + "no-cache,no-store" + "private,max-age=120" + "no-cache,max-age=0" + "private,no-cache" + "public,no-transform" "no-store,must-revalidate,max-age=0" "public,max-age=0" "private,s-maxage=60" "no-cache,max-age=30" - "immutable,max-age=3600" "no-store,s-maxage=120" - "max-age=300,must-revalidate" - "proxy-revalidate,max-age=600" - "no-transform,max-age=900" "public,no-cache" "private,no-store" - "must-revalidate,max-age=1200" - "proxy-revalidate,s-maxage=150" "no-cache,no-store,max-age=0" - "public,immutable,max-age=31536000" "private,max-age=60,must-revalidate" - "public,max-age=120,proxy-revalidate" "no-store,no-cache,must-revalidate,max-age=0" "private,immutable,s-maxage=43200" - "public,no-transform,s-maxage=60,max-age=30" - "max-age=60,no-transform,must-revalidate" ) - HITS=() - MISSES=() - - for CC in "${CACHE_CONTROLS[@]}"; do - curl -s -I "http://localhost/?cache_control=${CC}" > /dev/null - if $(curl -s -I "http://localhost/?cache_control=${CC}" | grep "X-Cache-Status" | grep -q "HIT"); then - HITS+=("$CC") - else - MISSES+=("$CC") - fi - done - - echo "Cache-Control directives that resulted in a HIT:" - for HIT in "${HITS[@]}"; do - echo "- $HIT" - done - echo "-----------------------------------" - echo "Cache-Control directives that resulted in a MISS:" - for MISS in "${MISSES[@]}"; do - echo "- $MISS" + for CC in "${CACHE_CONTROLS_HITS[@]}" "${CACHE_CONTROLS_MISSES[@]}"; do + curl -s -I "http://localhost/?cache_control=${CC}" > /dev/null + if $(curl -s -I "http://localhost/?cache_control=${CC}" | grep "X-Cache-Status" | grep -q "HIT"); then + if [[ " ${CACHE_CONTROLS_MISSES[@]} " =~ " $CC " ]]; then + echo "Error: HIT received for $CC" + exit 1 + else + echo "- HIT - $CC" + fi + else + if [[ " ${CACHE_CONTROLS_HITS[@]} " =~ " $CC " ]]; then + echo "Error: HIT expected for $CC" + exit 1 + else + echo "- MISS - $CC" + fi + fi done diff --git a/install/docker/config/nginx/onlyoffice-proxy.conf b/install/docker/config/nginx/onlyoffice-proxy.conf index 0990ceaf5ec..c9f97634c30 100644 --- a/install/docker/config/nginx/onlyoffice-proxy.conf +++ b/install/docker/config/nginx/onlyoffice-proxy.conf @@ -4,8 +4,8 @@ proxy_set_header Host $the_host; proxy_set_header X-Forwarded-Host $the_host; proxy_set_header X-Forwarded-Proto $the_scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; -more_clear_headers 'Server'; -more_clear_headers 'X-Powered-By'; +proxy_hide_header 'Server'; +proxy_hide_header 'X-Powered-By'; proxy_cache_path /var/cache/openresty levels=1:2 keys_zone=cache_proxy:10m max_size=1g inactive=24h use_temp_path=off;