I have a setup of the Nginx server (openresty) that has large files. When a client wants a range file Nginx sends 200 back instead of 206.
This is the example of my curl test:
curl -v -I -r 0- -X GET http://172.29.22.11/myBigFile.bin * Trying 172.29.22.11:80... * TCP_NODELAY set * Connected to 172.29.22.11 (172.29.22.11) port 80 (#0) > GET /myBigFile.bin HTTP/1.1 > Host: 172.29.22.11 > Range: bytes=0- > User-Agent: curl/7.68.0 > Accept: */* > * Mark bundle as not supporting multiuse < HTTP/1.1 200 OK HTTP/1.1 200 OK < Transfer-Encoding: chunked Transfer-Encoding: chunked < Connection: keep-alive Connection: keep-alive < Expires: Wed, 21 Dec 2022 09:10:00 GMT Expires: Wed, 21 Dec 2022 09:10:00 GMT < Cache-Control: max-age=31536000 Cache-Control: max-age=31536000 < Access-Control-Allow-Headers: * Access-Control-Allow-Headers: * < Access-Control-Allow-Origin: * Access-Control-Allow-Origin: * < myCacheStatus: HIT myCacheStatus: HIT < Pragma: public Pragma: public < Cache-Control: public Cache-Control: public < * Excess found: excess = 448 url =/myBigFile.bin A (zero-length body) * Connection #0 to host 172.29.22.11 left intact How can I define Nginx to return proper 206 on this?
----- Adding my configuration -----
location / { internal; proxy_cache my_cache; proxy_cache_key $uri; # set the ceching time for 200 respinse -> to 7 days proxy_cache_valid 200 7d; # Clear flags I dont want more_clear_headers 'Access-Control-Allow-Headers'; more_clear_headers 'Access-Control-Allow-Origin'; more_clear_headers 'access*'; more_clear_headers 'content-disposition'; more_clear_headers 'Date'; more_clear_headers 'x-proxy-cache'; more_clear_headers 'Server'; # add headers to handle CORS add_header Access-Control-Allow-Headers '*'; add_header Access-Control-Allow-Origin '*'; # to reduce Bandwisth I use compression gzip on; # set up the proxy, and instruct it to cech even if thre is no Cache-Control proxy_ignore_headers X-Accel-Expires Expires Cache-Control; proxy_cache_lock on; proxy_cache_lock_timeout 0s; proxy_cache_lock_age 200s; proxy_cache_use_stale updating; # the run reverse proxy proxy_pass http://0.0.0.0:3000; # set local ceching on the client side currently we will start at 365 days expires 365d; add_header Pragma public; add_header Cache-Control "public"; }