Serving dynamically generated files

Max nginxyz at mail.ru
Mon Feb 13 18:04:42 UTC 2012


 13 февраля 2012, 21:42 от Gregorio Hernández Caso : > Hi everybody, > > I'm trying to serve dynamically generated TXT files using PHP through > fastcgi_pass, but I have a problem that I can't solve. > This is what I have done: > > - The TXT files are going to be used by a "GPRS printer" that read them > from an url (ex: http://server/1234.txt) > - I have configured Nginx to rewrite the request of this files to a PHP > script > - The PHP script returns the TXT contents and the same headers as for an > static TXT file > - If a load the URL on a browser, the content and the headers are fine. > In fact, if I create the static TXT file with the same content of the PHP > generated, my browser shows me exactly the same. > > My problem is that the "printer" is not reading the TXT file correctly. > I know that the "printer" is working, because of two things: > > - If a create the static 1234.txt file, the "printer" prints it correctly > - When the printer reads the dynamically generated TXT file, the PHP > scripts also sends me an email, so I'm sure that the printer is connecting > to the URL. > > So, my question is... ¿is there any difference of how Nginx serves static > files towards dynamically generated ones? > > I've researched through internet and I cannot find an answer :-( First run "curl -v http://server/1234.txt" to make sure your PHP script is generating correct headers - in this case you should be sending "Content-Type: text/plain\r\n\r\n" before the actual content. A missing Content-Length header could also cause problems. Next, either enable debug level logging in nginx: error_log /var/log/nginx.error.log debug; or just use "nc -v -l 8080" on your server and have your "GPRS printer" connect to http://server:8080/1234.txt so you can check its request headers. Max
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20120213/c38264c7/attachment-0001.html>


More information about the nginx mailing list