【发布时间】:2016-12-22 21:24:15
【问题描述】:
谁能帮我把这个 apache 文件转换成 nginx。我最喜欢的网站名称是“neptix”。所以在浏览器中,我可以访问类似的内容:neptix/about-us、neptix/contact-us。注意:没有 .com
<VirtualHost 127.0.0.1>
ServerName neptix
ServerAlias *.neptix
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /api http://52.35.118.165/api
ProxyPassReverse /api http://52.35.118.165/api
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
<Location /api>
Order allow,deny
Allow from all
</Location>
DirectoryIndex index.html index.php
</VirtualHost>
【问题讨论】:
-
不清楚你问的是什么问题。
-
我正在尝试使用 'sitename' 而不是 'sitename.com' 设置 ServerName/ServerAlias .. 所以在浏览器中我可以输入站点名称,然后它会转到 localhost:3000。如果我点击页面,则 url 将是 'sitename/about-us'
-
您的浏览器需要知道输入“站点名称”时的去向,而这在 nginx 配置中无法做到。要在您自己的计算机上进行这项工作,您可以在主机文件中添加一个条目(Linux/OSX 上的 /etc/hosts,可能是 Windows 上的 C:\Windows\system32\drivers\etc\hosts),将站点名称映射到该文件的 ip服务器。您无法为每个人都这样做,因为您不能只定义自己的域。
标签: nginx