serving files from /proc
Francis Daly
francis at daoine.org
Tue Dec 12 17:42:15 UTC 2023
On Tue, Dec 12, 2023 at 04:17:11PM +0100, Jérôme Loyet wrote:
Hi there,
> I'm trying to serve some files from /proc but nginx return a 0 bytes
> content because the file size of many files in /proc/ tree is simply 0 by
> design.
I suspect that you are going to have to write something to read the file
and tell nginx what the "real" size and content is.
Stock nginx knows that for static files, when the filesystem says that
st_size is 0, the file has a size of 0. That happens to not be true for
some things within /proc; so either you get to change the code behind
/proc to return "real" values, or you get to write something to return
real values.
I guess it will be simpler to run something like a fastcgi process that
will "cat" the file, and tell nginx to fastcgi_pass to that process for
these requests; than to rewrite the /proc code or to rewrite the nginx
static file handler to do extra things when it is told that the size is 0.
> is there a simple way to configure nginx to return the cotent of
> /proc/net/route or any other file in /proc ?
Untested, but I suspect "directly: no; indirectly, maybe (as above)".
Cheers,
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list