Welcome! Log In Create A New Profile

Advanced

Re: NGINX perl module to server files

Maxim Dounin
September 01, 2013 09:28PM
Hello!

On Sun, Sep 01, 2013 at 04:29:46PM -0500, Jorge Sanchez wrote:

[...]

> So from above it turns out that there were no headers sent and thus the
> status code probably defaulted to "000" on NGINX.
>
> Adding the send_http_header before the $r->sendfile() solves the issue.
> $r->send_http_header();

Glad to see you've solved your problem with perl code.

BTW, there are some examples at
http://nginx.org/en/docs/http/ngx_http_perl_module.html which may
help.

> Now I have the correct HTTP status code, anyway the content type defaults
> to "application/octet-stream" which is configured as default content type
> on nginx. Well, is there a way to have NGINX correctly set the Content-Type
> after handling the request on perl content handler or should I make my own
> mapping and set the content-type myself in send_http_header ?

The Content-Type nginx set by itself is based on an extension as
seen in URI. As there is no extension in URIs you use, it uses
default type. If a default type isn't what you want - you should
either set response type explicitly, or reconsider URIs used.

In your particular case, I would recommend you to use
$r->internal_redirect() to an internal location instead of trying
to send files yourself. (Or, alternatively, perl_set + rewrite
should also work.) It should be much easier than trying to send
files yourself from perl.

See here for more details:

http://nginx.org/en/docs/http/ngx_http_perl_module.html

--
Maxim Dounin
http://nginx.org/en/donation.html

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

NGINX perl module to server files

Jorge Sanchez August 31, 2013 05:48PM

Re: NGINX perl module to server files

Jorge Sanchez September 01, 2013 05:30PM

Re: NGINX perl module to server files

Maxim Dounin September 01, 2013 09:28PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 162
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready