![](/img/trans.png)
[英]Apache + NginX reverse proxy: serving static and proxy files within nested URLs
[英]Nginx as reverse proxy for Apache not working - serving static file
我用nginx,php-fpm和apache配置了一个vps服务器。
通常,具有.html扩展名的网站 都像正常服务器一样作为静态网页进行服务器处理,但是当我尝试使用.php页面来动态生成内容时,我看到只有纯html代码(例如Nginx)正在提供.txt文件。
Nginx监听80,Apache监听8080。
禁用Mods: mod_proxy, mod_actions
Nginx服务器块配置:
server {
server_name example.com www.example.com;
listen 80;
root /var/www/example.com;
index index.php;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://IP:8080;
}
}
Apache虚拟主机配置:
<VirtualHost *:8080>
DocumentRoot /var/www/example.com
ServerName example.com
<Directory />
AllowOverride All
</Directory>
</VirtualHost>
Nginx和Apache都在%username%下工作,也使用%username%作为组。
代码似乎是正确的,但是问题是当我加载网页example.com/index.php时,它像使用纯html代码而不是常规.php页面的.txt文件一样被加载。
与info.php相同,通常使用"<?php phpinfo(); ?>"
我看到了代码,但没有看到真正的信息页面 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.