我用nginx和apache建立了本地機器。我使用nginx作爲所有nodejs通信的前端服務器。每個nodejs應用程序都有自己的上游定義,並在我的hosts文件中有一個條目,這樣我就可以得到一個方便的URL。另外,我有一個爲apache定義的上游,它在我的配置中工作在端口8080上 - 這樣我所有的php應用程序都可以在localhost/*(內部是localhost:8080/*)下使用。此配置現在可以正常工作幾個月。但是這次我想在本地機器上安裝magento安裝。爲此我加入127.0.0.1 magento.local
我的hosts文件(像我一樣對所有應用程序的NodeJS),並增加了以下我的nginx.conf:帶有nginx和Apache的虛擬主機
upstream apache {
server 127.0.0.1:8080;
}
server {
listen 80;
server_name magento.local;
client_max_body_size 1024M;
root /Users/phunkei/htdocs/magento;
location/{
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://apache;
}
}
這改寫一切/Users/phunkei/htdocs/
,這是我的Apache根。我已經嘗試向上遊定義server 127.0.0.1:8080/magento
添加子文件夾,但nginx不允許這樣做。
不知道你想達到的目標。但是'root'語句是多餘的。它不是必需的,也沒有使用。你想要做'proxy_pass http:// apache/magneto /;'? –
是的,它會爲網址添加「magento」,導致產生「http:// magento.local/magento」。我試圖讓'http://magento.local/'point到'/ Users/phunkei/htdocs/magento'或'http:// localhost:8080/magento' – Daniel