【发布时间】:2018-01-28 07:47:16
【问题描述】:
我有两个在 Linux EC2 AWS 实例上发布的 dotnet 项目,第一个项目在端口 5000 上,另一个在 50003 端口上。 我在第一个 conf.d 文件夹中创建了两个文件:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
ErrorLog /var/log/httpd/hellomvc-error.log
CustomLog /var/log/httpd/hellomvc-access.log common
和其他:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5003/
ProxyPassReverse / http://127.0.0.1:5003/
ErrorLog /var/log/httpd/hellomvc-error.log
CustomLog /var/log/httpd/hellomvc-access.log common
第二个只是一个 API。
我的问题是我可以毫无问题地在浏览器上打开第一个项目,但我无法访问第二个项目的 API,即使我可以使用 curl http://localhost:5003/api/Home 在本地访问它
【问题讨论】:
-
当您打开第一个项目时,您在浏览器地址栏中究竟输入了什么?尝试打开第二个项目时又输入了什么?
-
第一个我只输入IP,例如34.65.22.102,第二个我输入34.65.22.102/api/Home
-
Apache 需要一些准确的方法来决定服务于哪个站点。在您的情况下,它可以是(子)域名(例如
www.example.com和api.example.com)或 URI 路径(例如,将/api/*发送到项目 2,将其他所有内容发送到项目 1。您想要哪种方式是吗? -
我是新手,你能告诉我第二个项目配置文件应该是什么样子才能使用 URI 正确调用 API
标签: .net linux apache amazon-web-services amazon-ec2