Research on Nginx 400 error

Source: Internet
Author: User
Tags rfc

These days the game online in the View  Nginx  access log, found that there are many  HTTP  return codes for  400  records. The following is the access log for nginx :222.89.55.137 - - [27/dec/2014:19:35:15 +0800]  "POST / dia.php http/1.1 " 400 172 "-" "-" "-"    The website looked up a lot of documents. Solutions for 400 problems: 1. Modifying nginx configuration file   client_header_buffer_size 128k;large_client_header_buffers  4 128k;   in this way, the problem remains unresolved. 2. Add the default Config file   Add defaults to the server to the configuration file, the following configuration is explained here to prohibit the unbound domain name access   code as follows   copy code server {    listen 80  (www.111cn.net) default_server;   server_name _;    return 404;   access_log off; } from:http://www.111cn.net/sys/nginx/52851. htm  This method has also been tested and failed to solve.    then view the RFC document: A client must include a host header field in  all http/1.1 request messages . if the requested uri does  not&nbSp;include an internet host name for the service being requested,  then the host header field must be given with an empty  value. An HTTP/1.1 proxy MUST ensure that any request  Message it forwards does contain an appropriate host header field  that identifies the service being requested by the proxy.  all internet-based http/1.1 servers must respond with a 400  (Bad  request)  status code to any HTTP/1.1 request message which  Lacks a host header field. Above is an explanation of http1.1 's RfC about the host section,  from the above we learned that if a http1.1 request does not have a host domain,   Then server should send a 400 status code to the client segment,  indicates that this request server cannot process. For Nginx server,,  also follows this way, stating that the client sent an invalid request,  nginx&nbsThe p;server cannot be processed, so the status code of 400 is returned.   According to the above description analysis to determine is the client request http header  is not available caused by     So continue Google to the level of the Nginx error log to the info level to prove their judgment, the results are really rewarding,  the following information is Nginx errorlog: 2014/12/27 19:35:11  [info] 20798#0: *9705609 client sent invalid header line:  " User-agent: ^m based on the above error message that the client sent over the header  is wrong cause Nginx returned 400 error,  as to why the client sends the wrong header  information, I can only let the development to see.

This article from "Yaoshenshen" blog, declined reprint!

Research on Nginx 400 error

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.