Description
We just noticed
- NGINX returns HTTP 404 when an url (a plugin does not exist) when the HTTP method is GET or POST : that's OK.
- NGINX returns HTTP 405 when an url (a plugin does not exist) when the HTTP method is PUT, DELETE or PATCH : and we expected HTTP 404.
For exemple, let's assume we request an xxxx
plugin (url) that doesn't exist :
curl --location --request GET 'http://<url>:<port>/xxxx'
: nginx returns HTTP 404curl --location --request POST 'http://<url>:<port>/xxxx'
: nginx returns HTTP 404curl --location --request PUT 'http://<url>:<port>/xxxx'
: nginx returns HTTP 405curl --location --request DELETE 'http://<url>:<port>/xxxx'
: nginx returns HTTP 405curl --location --request PATCH 'http://<url>:<port>/xxxx'
: nginx returns HTTP 405
Have you ever had to deal with this kind of issue ?
We noticed in the nginx access.log
-
the
welcome
plugin is called in this case (url not found) for GET or POST method, but not for the other methods: e.g. (see"plugin": "welcome"
)
{ "@timestamp": "2021-02-22T17:29:51+01:00", "from": "192.168.72.139", "method": "GET", "uri": "/xxxx", "duration": 0.000, "status": 404, "request_length": 319, "reply_length": 2431, "plugin": "welcome", "request_id": "b15257dfffe6236e126b3b7da791bdec" }
-
the
welcome
plugin is not called in this case (url not found) for the other methods, e.g. (see"plugin": "#unknown#"
)
{ "@timestamp": "2021-02-22T17:30:17+01:00", "from": "192.168.72.139", "method": "PUT", "uri": "/xxxx", "duration": 0.000, "status": 405, "request_length": 318, "reply_length": 326, "plugin": "#unknown#", "request_id": "28617e034f064e06ca2457baa72273db" }
We found on some blogs to solve this issue, some people add dav_methods
in the nginx conf. (http://nginx.org/en/docs/http/ngx_http_dav_module.html), but I am not convinced this is the right solution.
Any idea ?