Clientbodyinfileonly - POST request is discarded

yurai nginx-forum at
Tue Oct 4 19:28:18 UTC 2016

Hello Nginx community,

I try to perform big file upload on my Nginx server basing on instructions
Unfortunately I get "HTTP/1.1 405 Not Allowed" error code all the time.

1. My minimal configuration:

worker_processes  1;

events {
    worker_connections  1024;

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

    sendfile        on;
    tcp_nopush on;
    tcp_nodelay on;
    types_hash_max_size 2048;
    keepalive_timeout  65;
    client_body_temp_path /tmp/nginx-client-body;

    server {
        listen       80;
        server_name  s1;

        location /upload {

                #auth_basic                 "Restricted Upload";
                #auth_basic_user_file       basic.htpasswd;

                client_body_temp_path /tmp/;
                client_body_in_file_only on;
                client_body_buffer_size 128K;
                client_max_body_size 1000M;

                proxy_pass_request_headers on;
                proxy_set_header X-FILE $request_body_file;
                proxy_set_body off;
                proxy_redirect off;

    server {
        listen       8080;
        server_name  s2;

        location / {
            root   /usr/share/nginx/html/foo/bar;
            autoindex on;

2. GET works as expected:

curl -i http://localhost/upload

HTTP/1.1 200 OK
Server: nginx/1.11.4
Date: Tue, 04 Oct 2016 19:05:42 GMT
Content-Type: text/plain
Content-Length: 4
Connection: keep-alive
Last-Modified: Tue, 04 Oct 2016 18:44:59 GMT
ETag: "57f3f8ab-4"
Accept-Ranges: bytes


It's OK - file upload.txt has "abc" content.

3. Unfortunately POST does not work:

curl --data-binary upload.txt http://localhost/upload

<head><title>405 Not Allowed</title></head>
<body bgcolor="white">
<center><h1>405 Not Allowed</h1></center>

I checked file content (actual request body) buffered in /tmp and it
contains expected file name ("upload.txt").
When I comment out auth_basic* directives in above config for both cases
(for GET and POST) I get "401 Authorization Required".
What did I miss?

Posted at Nginx Forum:,270063,270063#msg-270063

More information about the nginx mailing list