![](/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.