我用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