Welcome! Log In Create A New Profile

Advanced

nginx rewrites $request_method on error

kay
April 30, 2014 03:04AM
user nginx;
worker_processes 1;

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

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

# LET'S LOG $request_method #
log_format main '$request_method $remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

#HERE IS WHAT MAKES A BUG#
error_page 405 /error.html;

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

server {
listen 80;

if ($request_method != GET) {
return 405;
}

location / {
root /etc/nginx/www;
}
}

}

What we get:
1)
curl -X POST localhost
log:
GET 127.0.0.1 - - [30/Apr/2014:10:55:03 +0400] "POST / HTTP/1.1" 405 0 "-" "curl/7.26.0" "-"

2)
curl -X TRACE localhost
log:
GET 127.0.0.1 - - [30/Apr/2014:10:55:10 +0400] "TRACE / HTTP/1.1" 405 0 "-" "curl/7.26.0" "-"

3)
curl -X PUT localhost
log:
GET 127.0.0.1 - - [30/Apr/2014:10:55:18 +0400] "PUT / HTTP/1.1" 405 0 "-" "curl/7.26.0" "-"

Let's disable "if":
1) curl -X POST localhost
GET 127.0.0.1 - - [30/Apr/2014:10:58:48 +0400] "POST / HTTP/1.1" 405 0 "-" "curl/7.26.0" "-"
2) curl -X TRACE localhost
GET 127.0.0.1 - - [30/Apr/2014:10:59:12 +0400] "TRACE / HTTP/1.1" 405 0 "-" "curl/7.26.0" "-"
3) curl -X PUT localhost
GET 127.0.0.1 - - [30/Apr/2014:10:59:38 +0400] "PUT / HTTP/1.1" 405 0 "-" "curl/7.26.0" "-"

Let's disable "error_page 405 /error.html;"
1) curl -X POST localhost
POST 127.0.0.1 - - [30/Apr/2014:11:00:43 +0400] "POST / HTTP/1.1" 405 172 "-" "curl/7.26.0" "-"
2) curl -X TRACE localhost
TRACE 127.0.0.1 - - [30/Apr/2014:11:01:02 +0400] "TRACE / HTTP/1.1" 405 172 "-" "curl/7.26.0" "-"
3) curl -X PUT localhost
PUT 127.0.0.1 - - [30/Apr/2014:11:01:16 +0400] "PUT / HTTP/1.1" 405 172 "-" "curl/7.26.0" "-"

So it seems that error_page 405 /error.html rewrites $request_method
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: 300
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