【发布时间】:2020-03-11 22:00:22
【问题描述】:
我有一个 ASP.NET Core 2 Web API 项目和 Centos 7 Linux 服务器。
我在服务器中将项目作为服务运行。
它在我的服务器上运行 7/24。
如果我写到 Linux 终端 "wget http://localhost:5000/api/users --no-check-certificate",用户 json 文件会下载到我的服务器。这里没有问题。
但我无法从本地计算机访问我的 api。
如果我将 "http://[SERVER_IP]:[PORT]/api/users" 写入网络浏览器,它会返回 502 Bad Gateway Http 状态代码。
我该如何解决?
etc/nginx/nginx.conf
http {
...
server{
listen 12900;
location / {
proxy_pass http://195.201.150.228:5000;
}
}
}
【问题讨论】:
-
您将请求代理到
http://195.201.150.228:5000。你有没有配置你的服务器打开5000的端口? -
是的,我已经在vesta c面板中打开了5000端口。
-
您可以从远程计算机访问
http://195.201.150.228:5000吗? -
我解决了这个问题。我的服务器有vesta c面板。所以我不能将服务器块写入etc/nginx/nginx.conf。我创建了一个用户和一个名为 api.hocamnerede.com 的子域,并将服务器块写入 /home/Hocamnerede/conf/web/api.hocamnerede.com.nginx.conf .
标签: linux nginx server centos asp.net-core-webapi