Nginx error solution Summary

Source: Internet
Author: User
Tags connection reset

Nginx error optimization document

1. A large number of time_wait Cases

View:

Netstat-N | awk '/^ TCP/{++ s [$ NF]} end {for (a in S) printa. s [a]}'

 

Closed: No connection is active or in progress

Listen: the server is waiting for incoming call

Syn_recv: a connection request has arrived, waiting for confirmation

Syn_sent: The application has started. Open a connection.

Established: normal data transmission status

Fin_wait1: The application says it has been completed

Fin_wait2: the other side has agreed to release

Itmed_wait: wait until all groups die

Closing: both sides attempt to close at the same time

Time_wait: the other side has initialized a release.

Last_ack: waiting for all groups to die

Modify:

VI/etc/sysctl. conf

Net. ipv4.tcp _ syscookies = 1

Net. ipv4.tcp _ tw_reuse = 1

Net. ipv4.tcp _ tw_recycle = 1

Net. ipv4.tcp _ tw_fin_timeout = 30

/Sbin/sysctl-P

Net. ipv4.tcp _ syncookies = 1 indicates enabling syn cookies. When a SYN wait queue overflows, cookies are enabled to prevent a small number of SYN attacks. The default value is 0, indicating that the process is disabled;

Net. ipv4.tcp _ tw_reuse = 1 indicates enabling reuse. Allow time-Wait sockets to be re-used for a New TCP connection. The default value is 0, indicating that the TCP connection is disabled;

Net. ipv4.tcp _ tw_recycle = 1 indicates to enable quick recovery of Time-Wait sockets in TCP connections. The default value is 0, indicating to disable it.

Net. ipv4.tcp _ fin_timeout modifies the default timeout time of the system.


######################################## ######################################## ##


2. A large number of too upload open files appear in error. log.


Add the following PID in nginx. conf:

Worker_rlimit_nofile 655350;


VI/etc/security/limits. conf

* Soft nofile 655350

* Hard nofile 655350

To make limits. conf effective, you must ensure that the pam_limits.so file is added to the Startup File.


VI/etc/PAM. d/login

Add:

Session required/lib/security/pam_limits.so


######################################## #########################

Error_log:


14:02:42 [Error] 7357 #0: * 19 FastCGI sent in stderr: "primary script unknown" while reading response header from upstream, client: 192.168.2.15, server: localhost, request: "Get/index. php http/1.1 ", upstream:" FastCGI: // 192.168.2.22: 9000 ", host:" 192.168.2.22

 

Modify:

VI nginx. conf

Fastcgi_param script_name $ document $ fastcgi_script_name;

######################################## ###############################

Error. log:

16:14:31 [Error] 17029 #0: * 17941 Recv () failed (104: Connection reset by peer) while reading response header from upstream, client: 210.61.12.2, server: blog.lixiphp.com, request: "post/API/1.0 HTTP/1.1", upstream: "FastCGI: // 127.0.0.1: 9000", host: "blog.lixiphp.com"


Where: (104: Connection reset by peer)


VI php-fpm.conf

Request_terminate_timeout = 0 remove comments and change to 0

######################################## ################################


 


This article is from the "frequently used documentation" blog, please be sure to keep this source http://yujianglei.blog.51cto.com/7215578/1561589

Nginx error solution Summary

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.