Common problems and error handling in Nginx

Source: Internet
Author: User
Keywords Nginx FAQ error handling
Tags configuration error error handling gateway how to http nginx nginx.conf

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;

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.