简体   繁体   English

nginx(已安装php)proxy_pass指定目录到apache服务器(使用php-fpm)失败

[英]nginx (has php installed ) proxy_pass specified directory to apache server( with php-fpm) failed

Hope someones can give help. 希望有人能提供帮助。 we have two servers here, one is nginx + php-fpm, another is apache + php-fpm, they are in the same LAN. 我们这里有两台服务器,一台是nginx + php-fpm,另一台是apache + php-fpm,它们在同一局域网中。

In the nginx server we have php site www.xxx.com 在Nginx服务器中,我们有php网站www.xxx.com
And we also have php website pages on apache servers too. 而且我们在Apache服务器上也有php网站页面。 What we want is , when user accesss www.xxx.com/yyy/* the request will be send to apache server , the apache server and its php will handled the request. 我们想要的是,当用户访问www.xxx.com/yyy/*时,请求将被发送到apache服务器,apache服务器及其php将处理该请求。 At the same time, the URL www.xxx.com/yyy/* shouldn no be changed. 同时,不应更改URL www.xxx.com/yyy/*。

In the nginx server I added configuration in /etc/nginx/conf.d/xxx.conf like below: 在Nginx服务器中,我在/etc/nginx/conf.d/xxx.conf中添加了配置,如下所示:

location ^~ /yyy/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://10.47.127.226:8088/;    //the apache port is 8088
}

Then reload the nginx service, 然后重新加载nginx服务,
when we access www.xxx.com/yyy/ , it can load the page , but it can only display txt related information, No web page format or picture related dispalyed. 当我们访问www.xxx.com/yyy/时,它可以加载页面,但是只能显示与txt相关的信息,不会显示任何网页格式或图片。 (I can confirm the apache and its php is working fine, and I can directly access it normally via http://10.47.127.226:8088/ ) (我可以确认apache及其php正常工作,并且我可以通过http://10.47.127.226:8088/直接正常访问它)

So I am not sure if the request is possible? 所以我不确定是否可以提出要求? if possible, whatelse I can do for nginx ? 如果可能的话,我还能为nginx做些什么?

Thanks for your help ! 谢谢你的帮助 !

Thanks all for your help. 感谢你的帮助。 Finally I resolved the question. 最后,我解决了这个问题。 The root case is in apache server site. 根案例在apache服务器站点中。 in the php code, the url php generated without directory /yyy/, but it should have directory /yyy/ in generated url . 在php代码中,生成的php php没有目录/ yyy /,但是在生成的url中应该具有目录/ yyy /。 The developer added /yyy/to generated php url. 开发人员在生成的php URL中添加了/ yyy /。 and it worked. 而且有效。 The nginx proxy configuration is ok. Nginx代理配置正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM