我希望使用Nodejs/Apache代理传递来提供我的API,但是在添加下面的Apache(httpd)配置后,似乎配置没有起作用。
操作系统:
CentOS 6
/etc/httpd/conf/httpd.conf:
...
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /home/MyUser/public_html
<Directory />
Options -Indexes +FollowSymLinks
AllowOverride None
Require all granted
</Directory>
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
<Proxy *>
Require all granted
</Proxy>
<Location /api>
ProxyPass http://MyVpsIp:1337
ProxyPassReverse http://MyVpsIp:1337
</Location>
</VirtualHost>
...
之后:
sudo service httpd restart
在浏览器中打开example.com/api:
Not Found
The requested URL /api was not found on this server.
编辑: 当我在浏览器中打开 example.com:1337/api
时,一切正常!但我想要的是 example.com/api
http(s)://example.com/api/something => http://localhost/api/something
- Milad Jafari