Welcome! Log In Create A New Profile

Advanced

Clientbodyinfileonly - POST request is discarded

October 04, 2016 03:28PM
Hello Nginx community,

I try to perform big file upload on my Nginx server basing on instructions from
https://coderwall.com/p/swgfvw/nginx-direct-file-upload-without-passing-them-through-backend
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;
proxy_pass http://127.0.0.1:8080/upload.txt;
}
}

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

abc

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

3. Unfortunately POST does not work:

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

<html>
<head><title>405 Not Allowed</title></head>
<body bgcolor="white">
<center><h1>405 Not Allowed</h1></center>
<hr><center>nginx/1.11.4</center>
</body>
</html>

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?
Subject Author Posted

Clientbodyinfileonly - POST request is discarded

yurai October 04, 2016 03:28PM

Re: Clientbodyinfileonly - POST request is discarded

Francis Daly October 04, 2016 03:48PM

Re: Clientbodyinfileonly - POST request is discarded

yurai October 07, 2016 03:47PM

Re: Clientbodyinfileonly - POST request is discarded

Francis Daly October 09, 2016 12:06PM

Re: Clientbodyinfileonly - POST request is discarded

yurai October 10, 2016 03:41AM

Re: Clientbodyinfileonly - POST request is discarded

Francis Daly October 10, 2016 12:18PM

Re: Clientbodyinfileonly - POST request is discarded

yurai October 12, 2016 06:28AM

Re: Clientbodyinfileonly - POST request is discarded

Francis Daly October 12, 2016 12:04PM

Re: Clientbodyinfileonly - POST request is discarded

yurai October 12, 2016 03:34PM

Re: Clientbodyinfileonly - POST request is discarded

Francis Daly October 12, 2016 05:46PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 70
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready