Opened 10 years ago

Closed 7 years ago

#585 closed defect (fixed)

SSI include subrequests fails in big POST reply

Reported by: Hervé Bry Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.7.x
Keywords: ssi proxy Cc:
uname -a: Linux dev-www.liancourt.gnet 2.6.38.7-server-1mnb2 #1 SMP Sun May 22 21:22:07 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.7.2
built by gcc 4.4.3 (GCC)
TLS SNI support enabled
configure arguments: --with-http_stub_status_module --with-http_ssl_module --with-http_secure_link_module --with-http_sub_module --with-http_realip_module --with-ipv6 --prefix=/var/lib/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/body --http-proxy-temp-path=/var/lib/nginx/proxy --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --add-module=nginx-upload-progress-module-master

Description

In the following situation:

  • nginx is used as a proxy
  • SSI processing is enabled on nginx
  • a POST request is big enough that the body needs to be stored on disk
  • the reply of the POST request contains SSI include tags

The subrequests generated by the SSI includes fails with the following error :
[crit] 18249#0: *8455632166 pread() "/var/lib/nginx/body/0047817306" failed (9: Bad file descriptor) while sending request to upstream

In the end, the 502 error page is included instead of the requested URIs.

Reproducible using the following files:


location / {

ssi on;
proxy_pass http://backend;

}


<html>

<body>

<form action="test.html" enctype="multipart/form-data" method="post">

<input type="file" name="f"/>
<input type="submit"/>

</form>
<p><!--# include virtual="include.html" --></p>

</body>

</html>


This text will be included in test.html

Change History (4)

comment:1 by Hervé Bry, 10 years ago

The test file names disappeared in the bug description, but the first one is obviously the config, then test.html and include.html.

And I must add the bug seems similar to the one described in 2011 here : https://gist.github.com/saj/1057940

Last edited 10 years ago by Hervé Bry (previous) (diff)

comment:2 by Maxim Dounin, 10 years ago

Keywords: proxy added
Status: newaccepted

Thanks, this is known problem which happens due to an optimization in proxy module: request body cache file is released once a response is got. If later a subrequest tries to use body, it fails. It's unlikely to be fixed in foreseeable future though. Workaround is to use "proxy_pass_request_body off" for subrequests.

comment:3 by Roman Arutyunyan <arut@…>, 7 years ago

In 7070:f583559aadc7/nginx:

Upstream: keep request body file from removal if requested.

The new request flag "preserve_body" indicates that the request body file should
not be removed by the upstream module because it may be used later by a
subrequest. The flag is set by the SSI (ticket #585), addition and slice
modules. Additionally, it is also set by the upstream module when a background
cache update subrequest is started to prevent the request body file removal
after an internal redirect. Only the main request is now allowed to remove the
file.

comment:4 by Roman Arutyunyan, 7 years ago

Resolution: fixed
Status: acceptedclosed
Note: See TracTickets for help on using tickets.