nginx rewrites $request_method on error

kay nginx-forum at nginx.us
Thu May 15 06:19:03 UTC 2014


Here is nginx version:
nginx -V
nginx version: nginx/1.6.0
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) 
TLS SNI support enabled
configure arguments: --add-module=ngx_devel_kit-0.2.19
--add-module=lua-nginx-module-0.9.7 --add-module=memc-nginx-module-0.14
--user=apache --group=apache --prefix=/usr/share/nginx
--sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log
--http-client-body-temp-path=/var/lib/nginx/tmp/client_body
--http-proxy-temp-path=/var/lib/nginx/tmp/proxy
--http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi
--pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx
--with-pcre=pcre-8.35 --with-pcre-jit --with-debug --with-md5-asm
--with-sha1-asm --without-mail_pop3_module --without-mail_imap_module
--without-mail_smtp_module --with-http_ssl_module --with-http_realip_module
--with-http_gzip_static_module --with-http_stub_status_module
--with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'

Here is minimal config:
worker_processes 1;

error_log /var/log/nginx/error.log debug;
pid /var/run/nginx.pid;

events {
        worker_connections 1024;
}

http {
        error_page 405 /error.html;
        error_page 400 /error.html;
        error_page 403 /error.html;

        server {
                listen 8080;
                        location / {
                                access_by_lua '
                                        local res =
ngx.location.capture("/memc?cmd=get&key=test")
                                        return
                                ';
                                root /etc/nginx/www;
                        }
                        location /memc {
                                internal;
                                set $memc_key $arg_key;
                                set $memc_cmd $arg_cmd;
                                memc_pass localhost:11211;
                        }
        }
}

/etc/nginx/www content:
ls /etc/nginx/www
error.html

curl -X GET localhost works fine (processes 403)
curl -X POST localhost works fine (processes 403)

Here is debug log on curl -X TRACE localhost or curl -X anythinghere
localhost:
2014/05/15 09:59:17 [debug] 15900#0: epoll: fd:6 ev:0001 d:00007FC4FBE03010
2014/05/15 09:59:17 [debug] 15900#0: accept on 0.0.0.0:80, ready: 0
2014/05/15 09:59:17 [debug] 15900#0: posix_memalign: 0000000000D4AD30:256
@16
2014/05/15 09:59:17 [debug] 15900#0: *3 accept: 127.0.0.1 fd:3
2014/05/15 09:59:17 [debug] 15900#0: posix_memalign: 0000000000D4AE90:256
@16
2014/05/15 09:59:17 [debug] 15900#0: *3 event timer add: 3:
60000:1400133617621
2014/05/15 09:59:17 [debug] 15900#0: *3 reusable connection: 1
2014/05/15 09:59:17 [debug] 15900#0: *3 epoll add event: fd:3 op:1
ev:80002001
2014/05/15 09:59:17 [debug] 15900#0: timer delta: 6573
2014/05/15 09:59:17 [debug] 15900#0: posted events 0000000000000000
2014/05/15 09:59:17 [debug] 15900#0: worker cycle
2014/05/15 09:59:17 [debug] 15900#0: epoll timer: 60000
2014/05/15 09:59:17 [debug] 15900#0: epoll: fd:3 ev:0001 d:00007FC4FBE031C1
2014/05/15 09:59:17 [debug] 15900#0: *3 http wait request handler
2014/05/15 09:59:17 [debug] 15900#0: *3 malloc: 0000000000D653D0:1024
2014/05/15 09:59:17 [debug] 15900#0: *3 recv: fd:3 78 of 1024
2014/05/15 09:59:17 [debug] 15900#0: *3 reusable connection: 0
2014/05/15 09:59:17 [debug] 15900#0: *3 posix_memalign:
0000000000D571B0:4096 @16
2014/05/15 09:59:17 [debug] 15900#0: *3 http process request line
2014/05/15 09:59:17 [debug] 15900#0: *3 http request line: "TRACE /
HTTP/1.1"
2014/05/15 09:59:17 [debug] 15900#0: *3 http uri: "/"
2014/05/15 09:59:17 [debug] 15900#0: *3 http args: ""
2014/05/15 09:59:17 [debug] 15900#0: *3 http exten: ""
2014/05/15 09:59:17 [debug] 15900#0: *3 http process request header line
2014/05/15 09:59:17 [debug] 15900#0: *3 http header: "User-Agent:
curl/7.26.0"
2014/05/15 09:59:17 [debug] 15900#0: *3 http header: "Host: localhost"
2014/05/15 09:59:17 [debug] 15900#0: *3 http header: "Accept: */*"
2014/05/15 09:59:17 [debug] 15900#0: *3 http header done
2014/05/15 09:59:17 [info] 15900#0: *3 client sent TRACE method while
reading client request headers, client: 127.0.0.1, server: , request: "TRACE
/ HTTP/1.1", host: "localhost"
2014/05/15 09:59:17 [debug] 15900#0: *3 http finalize request: 405, "/?"
a:1, c:1
2014/05/15 09:59:17 [debug] 15900#0: *3 event timer del: 3: 1400133617621
2014/05/15 09:59:17 [debug] 15900#0: *3 http special response: 405, "/?"
2014/05/15 09:59:17 [debug] 15900#0: *3 internal redirect: "/error.html?"
2014/05/15 09:59:17 [debug] 15900#0: *3 rewrite phase: 1
2014/05/15 09:59:17 [debug] 15900#0: *3 test location: "/"
2014/05/15 09:59:17 [debug] 15900#0: *3 test location: "memc"
2014/05/15 09:59:17 [debug] 15900#0: *3 using configuration "/"
2014/05/15 09:59:17 [debug] 15900#0: *3 http cl:-1 max:1048576
2014/05/15 09:59:17 [debug] 15900#0: *3 rewrite phase: 3
2014/05/15 09:59:17 [debug] 15900#0: *3 post rewrite phase: 4
2014/05/15 09:59:17 [debug] 15900#0: *3 generic phase: 5
2014/05/15 09:59:17 [debug] 15900#0: *3 generic phase: 6
2014/05/15 09:59:17 [debug] 15900#0: *3 generic phase: 7
2014/05/15 09:59:17 [debug] 15900#0: *3 access phase: 8
2014/05/15 09:59:17 [debug] 15900#0: *3 access phase: 9
2014/05/15 09:59:17 [debug] 15900#0: *3 access phase: 10
2014/05/15 09:59:17 [debug] 15900#0: *3 lua access handler,
uri:"/error.html" c:2
2014/05/15 09:59:17 [debug] 15900#0: *3 posix_memalign:
0000000000D4F2B0:4096 @16
2014/05/15 09:59:17 [debug] 15900#0: *3 lua creating new thread
2014/05/15 09:59:17 [debug] 15900#0: *3 lua reset ctx
2014/05/15 09:59:17 [debug] 15900#0: *3 http cleanup add: 0000000000D58118
2014/05/15 09:59:17 [debug] 15900#0: *3 lua run thread, top:0 c:2
2014/05/15 09:59:17 [debug] 15900#0: *3 lua location capture,
uri:"/error.html" c:2
2014/05/15 09:59:17 [debug] 15900#0: *3 http subrequest
"/memc?cmd=get&key=test"
2014/05/15 09:59:17 [debug] 15900#0: *3 posix_memalign:
0000000000D502C0:4096 @16
2014/05/15 09:59:17 [debug] 15900#0: *3 lua resume returned 1
2014/05/15 09:59:17 [debug] 15900#0: *3 lua thread yielded
2014/05/15 09:59:17 [debug] 15900#0: *3 http finalize request: -4,
"/error.html?" a:1, c:3
2014/05/15 09:59:17 [debug] 15900#0: *3 http request count:3 blk:0
2014/05/15 09:59:17 [debug] 15900#0: timer delta: 0
2014/05/15 09:59:17 [debug] 15900#0: posted events 0000000000000000
2014/05/15 09:59:17 [debug] 15900#0: worker cycle
2014/05/15 09:59:17 [debug] 15900#0: epoll timer: -1 <<<< Here nginx hangs
on

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,249754,250101#msg-250101



More information about the nginx mailing list