Welcome! Log In Create A New Profile

Advanced

Re: nginx rewrites $request_method on error

Yichun Zhang (agentzh)
May 07, 2014 05:42PM
Hello!

On Tue, May 6, 2014 at 11:30 PM, kay wrote:
> Sure, you can use nginx.conf from my previous message and this server
> config:
>

I've noticed 2 obvious mistakes in your config. See blow.

> server {
> listen 80;
>
> rewrite_by_lua '
> local res = ngx.location.capture("/memc?cmd=get&key=test")
> ngx.say(res.body)
> ';
>

1. It is not recommended to use the rewrite_by_lua directive directly
in the server {} block. Because this rewrite_by_lua directive will
just get inherited by every location in that server {} block by
default, including 1) your location /memc, which will create a
subrequest loop because you initiate a subrequest in your
rewrite_by_lua code to /memc, and 2) your error pages like
/error.html. And I'm sure this is not what you want.

2. If you generate a response in rewrite_by_lua by calls like
"ngx.say()", then you should really terminate the current request
immediately, via "ngx.exit(200)" or something like that, otherwise
nginx will continue to run later phases like the "content phase"
(which is supposed to generate a response) and you will face duplicate
responses for the same request.

Another suggestion is to check out your nginx error logs for hints (if
any). If the existing info is not enough, you can further enable
nginx's debugging logs: http://nginx.org/en/docs/debugging_log.html

Finally, ensure your version of ngx_lua, ngx_memc, and the nginx core
are recent enough.

Good luck!
-agentzh

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

nginx rewrites $request_method on error

kay April 30, 2014 03:04AM

Re: nginx rewrites $request_method on error

kay April 30, 2014 03:21AM

Re: nginx rewrites $request_method on error

Maxim Dounin April 30, 2014 10:42AM

Re: nginx rewrites $request_method on error

kay May 06, 2014 05:58AM

Re: nginx rewrites $request_method on error

Yichun Zhang (agentzh) May 06, 2014 06:30PM

Re: nginx rewrites $request_method on error

kay May 07, 2014 02:30AM

Re: nginx rewrites $request_method on error

Yichun Zhang (agentzh) May 07, 2014 05:42PM

Re: nginx rewrites $request_method on error

kay May 07, 2014 11:59PM

Re: nginx rewrites $request_method on error

Yichun Zhang (agentzh) May 08, 2014 03:30PM

Re: nginx rewrites $request_method on error

kay May 14, 2014 02:52AM

Re: nginx rewrites $request_method on error

Yichun Zhang (agentzh) May 14, 2014 04:18PM

Re: nginx rewrites $request_method on error

kay May 15, 2014 02:19AM

Re: nginx rewrites $request_method on error

Yichun Zhang (agentzh) May 15, 2014 03:22PM

Re: nginx rewrites $request_method on error

kay May 16, 2014 02:56AM

Re: nginx rewrites $request_method on error

kay May 16, 2014 03:16AM

Re: nginx rewrites $request_method on error

Yichun Zhang (agentzh) May 16, 2014 04:28PM

Re: nginx rewrites $request_method on error

Maxim Dounin May 19, 2014 07:34AM

Re: nginx rewrites $request_method on error

Yichun Zhang (agentzh) May 19, 2014 02:50PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 119
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