sx Luo
sx Luo

Reputation: 79

When I use the delete protocol of HTTP to pass parameters in the body (the parameters are very small), nginx returns 413, why?

Like this :

[root@localhost orz]# 
[root@localhost orz]# 
[root@localhost orz]# curl -X 'DELETE'   'http://192.168.6.166:7777/api/services/group/'   -H 'accept: application/json'   -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTY0MDU4MDAwN30.dPO-jUjoa78iDMVkyruhzbhrW7PTCMwJGtApMShSfa0'   -H 'Content-Type: application/json'   -d '{                      
  "groups_id": ["54"]
}'
<html><body><h1>413 Payload Too Large</h1>
The request entity exceeds the maximum allowed.
</body></html>
[root@localhost orz]# 
[root@localhost orz]# 

If I change to post, it will be fine. I mean nginx won't return 413,The parameter transmitted from the delete protocol request body causes nginx to return 413. Other protocols do not have this problem:

[root@localhost orz]# 
[root@localhost orz]# 
[root@localhost orz]# 
[root@localhost orz]# 
[root@localhost orz]# curl -X 'POST'   'http://192.168.6.166:7777/api/services/group/'   -H 'accept: application/json'   -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTY0MDU4MDAwN30.dPO-jUjoa78iDMVkyruhzbhrW7PTCMwJGtApMShSfa0'   -H 'Content-Type: application/json'   -d '{
  "groups_id": ["54"]
}'
{"detail":[{"loc":["body","name"],"msg":"field required","type":"value_error.missing"},{"loc":["body","groups_id"],"msg":"extra fields not permitted","type":"value_error.extra"}]}[root@localhost orz]# 
[root@localhost orz]# 
[root@localhost orz]# 
[root@localhost orz]# 

I don't understand why and how to solve this problem!Can anyone help me? thanks Here is my nginx configuration:

#user  root;
worker_processes  2;

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


events {
        use epoll;
        multi_accept on;
    worker_connections  1024;
}


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

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

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

    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay     on;
    keepalive_timeout  65;
    client_max_body_size 100m;
    #gzip  on;

#    include /etc/nginx/conf.d/*.conf;


        server{
                listen 8888;
                server_name 192.168.6.166;
                #root /data/www/test;
#               index index.html index.htm;

                location / {
                        index index.html;
                }

                location /api/ {
                        proxy_pass http://192.168.6.166:8000/;
                }

                location ~ .*\.(js|css)?$
                {
                        expires      12h;
                }
        }
}

Upvotes: 4

Views: 817

Answers (2)

Zheng Jindou
Zheng Jindou

Reputation: 1

proxy_http_version 1.1 add this config

Upvotes: 0

user25582090
user25582090

Reputation: 1

maybe you need to add paramter: proxy_http_version 1.1

Upvotes: 0

Related Questions