A
A
Alexander Urich2017-01-09 23:27:18
Nginx
Alexander Urich, 2017-01-09 23:27:18

Why can nginx return 400?

The application sends files with an HTTP POST request.
Everything comes fine to Apache, but nginx does not let it through and gives 400.
What can he not like?
Moreover, I send the same request via curl - there is no error ...
I quote the headers:
Working headers (from a request that is processed normally, I send it with a curl):

host: 123.45.56
user-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Название приложения
content-type: multipart/form-data; boundary=5873ed5c762ec
content-length: 432929

Headers from the application, the request with which does not pass:
host: 123.45.56
user-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Название приложения
accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
accept-language: en-us,en;q=0.5
accept-encoding: gzip,deflate
accept-charset: windows-1251,utf-8;q=0.7,*;q=0.7
keep-alive: 300
connection: keep-alive
content-type: multipart/form-data; boundary=---------------------------587132587349317
content-length: 300000

Change headers sent by application - no option...
nginx configs:
nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

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

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        gzip on;
        gzip_disable "msie6";

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

default.conf
server {
    charset utf-8;
    client_max_body_size 128M;

    client_header_buffer_size 4k;
    large_client_header_buffers 8 16k;

    listen 80 default_server;

    server_name "";
    root        /home/user/www/web/domain.ru;
    index       index.php index.html index.htm;

    access_log  /home/user/www/log/access.log;
    error_log   /home/user/www/log/error.log;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.(js|css|png|jpg|gif|swf|ico|mov|fla|zip|rar)$ {
        try_files $uri =404;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/run/php/php-fpm.sock;
        proxy_read_timeout 600;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        fastcgi_param PHP_VALUE "sendmail_path=/usr/sbin/sendmail -t -i -f [email protected]";
        fastcgi_param PHP_ADMIN_VALUE "open_basedir=/home/user/www/:.";
        fastcgi_param PHP_ADMIN_VALUE "upload_tmp_dir=/home/user/www/tmp";
        fastcgi_param PHP_ADMIN_VALUE "session.save_path=/home/user/www/tmp";
        fastcgi_param PHP_ADMIN_VALUE "display_errors=On";
        try_files $uri =404;
    }
}

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
ky0, 2017-01-09
@ky0

Are the method and url the same in both cases?

A
Andrey Mikhalev, 2017-01-10
@Endru9

and show nginx config? read
here ?

A
Alexander Urich, 2017-01-10
@Urichalex

read here?

well yes. In Google was of course

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question