1. Bad Request error reasons and Solutions
Configuration nginx.conf Related settings are as follows.
Client_header_buffer_size 16k;
Large_client_header_buffers 4 64k;
According to the specific situation adjustment, the general appropriate adjustment value can be.
2, Nginx 502 Bad Gateway Error
Proxy_next_upstream Error timeout invalid_header http_500 http_503;
Or try setting:
Large_client_header_buffers 4 32k;
3, Nginx appeared 413 Request Entity Too SCM Error
This error usually occurs when uploading files,
Edit Nginx main configuration file nginx.conf, locate http{} section, add
Client_max_body_size 10m; How much to set up according to their own needs for adjustment.
If you run PHP, this size client_max_body_size to be consistent with or slightly larger than the maximum value of the following value in PHP.ini, so that there is no error in submitting data size inconsistencies.
Post_max_size = 10M
Upload_max_filesize = 2M
4, solve 504 Gateway time-out (nginx)
This problem is encountered when upgrading the Discuz forum
In general, this situation may be due to the Nginx default fastcgi process response buffer too small, which will cause the fastcgi process to be suspended, if your fastcgi service to this suspend processing is not good, then it is very likely to cause the 504 Gateway Time-out
Now the site, especially some forums have a lot of replies and a lot of content, a page even has hundreds of K.
The default fastcgi process response buffer is 8K and we can set the larger point
In nginx.conf, add: Fastcgi_buffers 8 128k
This means that the fastcgi buffer is set to 8x128k
Of course, if you are doing an immediate operation, you may need to nginx the timeout parameter, for example, set to 60 seconds:
Send_timeout 60;
Just adjusted the two parameters, the result is no longer show that timeout, you can say that the effect is good, but also may be due to other reasons, the current information on Nginx is not a lot of things need long-term experience cumulative only results, look forward to your discovery ha!
5. How to use Nginx Proxy
Friend a server running Tomcat for 8080 ports, ip:192.168.1.2:8080, another machine ip:192.168.1.8. Friends want to access the Tomcat service by accessing the http://192.168.1.8. Configuration is as follows:
The nginx.conf on 192.168.1.8 is configured as follows:
server {
Listen 80;
server_name java.linuxtone.org
Location/{
Proxy_pass http://192.168.1.2:8080;
include/usr/local/nginx/conf/proxy.conf;
}
}
6. How to close Nginx log
Access_log/dev/null;
Error_log/dev/null;