0
我设置了nginx和apache的负载均衡。 nginx是反向代理,在2个独立的系统中有2个apache web服务器。为什么在使用nginx的负载均衡器中,它不会在其他服务器中找到文件?
在我的机器上,当我要求localhost
时,它工作正常。但如果我要求一个文件(例如info.php
)可用于其他2台服务器,它无法找到它并且一直显示本地info.php
文件,并且从未在其他服务器上显示info.php
文件。 如果我从我的机器上删除此文件(info.php
),它会显示我404错误。
这是我nginx的设置:
upstream localhost {
ip_hash;
server 1.2.3.4;
server 1.2.3.5;
}
server {
listen 80;
listen [::]:80;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name localhost;
location/{
try_files $uri $uri/ =404;
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_redirect off;
proxy_pass http://localhost;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
文件info.php
可以用2台其它服务器。
我改成了像你说的,但现在大约需要60秒加载apache的索引页,和以前一样,它不能显示info.php的其他服务器上的文件。 – msln
为什么会显示'info.php'?你的位置〜\ .php $ {'特别发送每个php请求到'fastcgi_pass unix:/run/php/php7.0-fpm.sock;' –
所以,我应该写什么呢?只是评论或写点别的东西? – msln