Nginx+php changed the address after Fastcgi_pass PHP does not request normally

Source: Internet
Author: User
Tags fpm php server connection reset

1.1.1 Install Nginx and PHP through Yum, change the address of nginx inside Fastcgi_pass PHP can not request the normal
1.1.1.1 problem Restore:
The nginx+php server address is 10.0.0.41/24
Nginx installation is 1.14 PHP installation is 7.1,yum installation process is not detailed

nginx的location里面的配置如下location ~ \.php$ {  root           /usr/share/nginx/html;  fastcgi_pass   10.0.0.41:9000;  fastcgi_index  index.php;  fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name;  include        fastcgi_params;  }php-fpm配置文件更改的位置为:listen = 10.0.0.41:9000这个时候在/usr/share/nginx/html下面写了一个php的测试页[[email protected] ~]# cat /usr/share/nginx/html/test.php <?phpphpinfo();?>

Then access the 10.0.0.41/test.php in the browser

1.1.1.2 Analysis and Solution:
Then analyze the possible cause of error 502: The bad geteway is not literal meaning, this place is basically php-fpm the time of the request is not normal, and then began to the back section of the error
View access logs, and error logs

访问日志:10.0.0.1 - - [30/Aug/2018:01:46:02 -0400] "GET /test.php HTTP/1.1" 200 95137 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" "-"10.0.0.1 - - [30/Aug/2018:02:18:05 -0400] "GET /test.php HTTP/1.1" 502 575 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" "-"错误日志:2018/08/30 02:18:05 [error] 9609#9609: *4 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 10.0.0.1, server: localhost, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://10.0.0.41:9000", host: "10.0.0.41"意思就是请求这个主机的10.0.0.41:9000端口失败

Then go to see if the firewall and SELinux shutdown, 9000 port is normal, found that the firewall and SELinux are closed, 9000 port is also normal monitoring.
This time want to be sure is php-fpm forwarding again problem, began to look for configuration files, see if there is a problem monitoring
Vim/etc/php-fpm.d/www.conf
Search inside the listen listen to the relevant content, find a listen.allowed_clients statement
Listen.allowed_clients = 127.0.0.1, when I saw this, I knew it could be a php config file, and we're going to allow clients to access it through this address.
Change to listen.allowed_clients = 10.0.0.41
Test found normal after saving restart PHP service. Problem solved.

Nginx+php changed the address after Fastcgi_pass PHP does not request normally

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.