I found a lot of 400 errors in the log today
The standard of http1.1 stipulates that the request must contain header information. If the request header is empty, the web server directly returns 400. For details, please see the RFC document RFC 2316, section 14.23
In addition to the above The telnet method may cause empty request headers. When the browser downloads pictures and clicks on other links at the same time, the download connection will be closed, empty request headers may also appear, or empty request headers may be accessed by robots.
Remove the 400 method in the access log
The version of nginx before 0.7.12 received an empty request, nginx will not match any virtual host, and directly returns a 400 error. The new version of nginx after
can use server_name _ ; Matches empty request headers.
So if you are using an old version, upgrade it to a version after 0.7.12 first
Add the following default virtual host server after the upgrade.
Add the default server to the configuration file. For an explanation of the following configuration, see here to prohibit unbound domain name access.
server { listen 80 default_server; server_name _; return 404; access_log off; }
It is recommended to save the above server as default.conf, and then include it in the main configuration file nginx.conf.
The above introduces nginx 400 bad request errors, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.