Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux Nginx负载平衡器,具有两个负载平衡的Nginx+;php fpm(主脚本未知)错误_Linux_Nginx_Load Balancing_Fastcgi_Php - Fatal编程技术网

Linux Nginx负载平衡器,具有两个负载平衡的Nginx+;php fpm(主脚本未知)错误

Linux Nginx负载平衡器,具有两个负载平衡的Nginx+;php fpm(主脚本未知)错误,linux,nginx,load-balancing,fastcgi,php,Linux,Nginx,Load Balancing,Fastcgi,Php,我们有两台带有nginx+php fpm(10.0.0.10和10.0.0.20)的web服务器,它在另一台nginx服务器(仅为nginx)后面进行负载平衡,当我们尝试浏览时,会发现文件未找到错误,错误日志列在底部 负载平衡器(10.0.0.1) nginx.conf upstream test_rack { server 10.0.0.10:80; server 10.0.0.20:80; } server { location / { proxy_p

我们有两台带有nginx+php fpm(10.0.0.10和10.0.0.20)的web服务器,它在另一台nginx服务器(仅为nginx)后面进行负载平衡,当我们尝试浏览时,会发现文件未找到错误,错误日志列在底部

负载平衡器(10.0.0.1)

nginx.conf

upstream test_rack {
    server 10.0.0.10:80;
    server 10.0.0.20:80;
}

server {
    location / {
       proxy_pass http://test_rack;
     }
}}
上游服务器(10.0.0.20)

subdomains.conf

server {
listen       80;
server_name ~^(?<sub>.+)\.example\.com$;

root /data/vhost/$sub.example.com/htdocs;

location / { 
    try_files $uri /index.php;
 }


location ~ \.php$ {
    fastcgi_pass   unix:/var/run/php5-fpm.sock;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
    include        fastcgi_params;
}}     

添加
proxy\u set\u头主机$Host到第一个nginx

否则,您的上游将获得
test\u rack
,而不是原始主机名,
$sub
变量为空

*1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 10.0.0.1, server: ~^(?<sub>.+)\.example\.com$, request: "GET / HTTP/1.0", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "test_rack"
fastcgi_param  SCRIPT_FILENAME   /data/vhost/$sub.example.com/htdocs/$fastcgi_script_name;