php - Ngnix + Apache/php-frm 502 网关错误
问题描述
尝试在两个不同的服务器上设置 Nginx 作为反向代理和 Apache 2.4.37 / php-frm 7.4.7。收到 502 bad gateway 错误消息,这是 Nginx 服务器的日志。
2021/08/16 15:40:27 [错误] 6550#0: *18 connect() 在连接到上游时失败(111:连接被拒绝),客户端:192.168.0.100,服务器:aaa.bbb,请求:“GET /wp-admin/admin.php?page=followup-emails HTTP/1.1”,上游:“fastcgi://10.0.0.35:9001”,主机:“aaa.bbb”,推荐人:“https://aaa. bbb/wp-admin/"
Nginx 上的配置:10.0.0.41
server {
listen 443;
client_header_buffer_size 64k;
large_client_header_buffers 4 64k;
server_name aaa.bbb;
#FASTCGI
set $skip_cache 0;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $skip_cache 1;
}
if ($query_string != "") {
set $skip_cache 1;
}
# Don't cache uris containing the following segments
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|/wp-admin/tools.php|index.php|sitemap(_index)?.xml") {
set $skip_cache 1;
}
# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $skip_cache 1;
}
location / {
proxy_cache proxycache;
proxy_buffering on;
proxy_cache_bypass $http_cache_control;
add_header X-Proxy-Cache $upstream_cache_status;
proxy_no_cache $http_pragma $http_authorization $cookie_nocache $arg_nocache;
proxy_pass http://10.0.0.35:80;
proxy_read_timeout 90;
proxy_connect_timeout 90;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
add_header Cache-Control "public";
add_header X-Real-IP $remote_addr;
proxy_set_header HTTP_X_FORWARDED_PROTO $scheme;
}
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
add_header rt-Fastcgi-Cache $upstream_cache_status;
include /etc/nginx/fastcgi_params;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param SCRIPT_FILENAME /var/www/staging/public_html$fastcgi_script_name;
# Use the upstream for php5-fpm that we defined in nginx.conf
fastcgi_pass 10.0.0.35:9001;
fastcgi_index index.php;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache phpcache_staging;
fastcgi_cache_valid 60m;
}
}
server {
listen 80;
server_name aaa.bbb;
return 301 https://$host$request_uri;
}
在 Apache 上配置,10.0.0.35
<VirtualHost *:80>
ServerName aaa.bbb
DocumentRoot /var/www/staging/public_html
LimitRequestFieldSize 1000000000
LimitRequestLine 1000000000
<Directory /var/www/staging/public_html>
AllowOverride All
</Directory>
<IfModule proxy_fcgi_module>
<Proxy "fcgi://127.0.0.1:9001/" enablereuse=on max=50>
ProxySet timeout=1800
</Proxy>
<FilesMatch "\.php$">
<If "-f %{REQUEST_FILENAME}">
SetHandler "proxy:fcgi://127.0.0.1:9001"
</If>
</FilesMatch>
</IfModule>
</VirtualHost>
网络统计-an | grep :9001 tcp 0 0 127.0.0.1:9001 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:9001 127.0.0.1:38312 已建立
有什么线索吗?
解决方案
推荐阅读
- mysql - MYSQL 错误 #2014:结果集为空时在存储过程中
- android - org.gradle.internal.component.AmbiguousVariantSelectionException
- java - 从 ExecutorService 调用同步方法无法正常工作
- vb.net - 由于符号不匹配或数据溢出以外的原因无法转换数据值
- c++ - C ++在循环内添加计数器变量并再次初始化其值
- selenium - 如何使用 Selenium 自动化 HTML5 日期选择器?
- python - 在情节图中标记特殊日子
- firebase - Firebase ShortDynamicLink not completing task
- javascript - 当我使用 onSelectRow 事件时,jqgrid 编辑按钮链接不起作用
- r - 计算非线性模型的置信区间:predictNLS 中的错误