我想询问有关要发送到ASP.Net Core应用程序的HTTP请求。
我想向nginx发送一个HTTP GET请求,nginx应该将该请求路由到ASP.NET Core应用程序,如下所示:
[ http://localhost:8060/api/serverconf/ Authentication Bearer {JWT} ]
上述查询应按以下方式路由到nginx:
[ http://localhost:4000/api/serverconf/ Authentication Bearer {JWT} ]
Nginx使用端口号:8060
ASP.NET Core Application在端口号4000上工作
操作系统是:Windows 10
当我检查错误消息时,它在行尾告诉我,如下所示:
2019/01/28 09:42:13 [error] 25220#24100: *5 "G:\AllFiles\Projeler\CSharpProjeler\DotNetCore\SemanticWebService\V2\SemanticAPI\nginx-1.5.4\nginx-1.5.4/html/api/serverconf/index.html" is not found (3: The system cannot find the path specified), client: 127.0.0.1, server: , request: "GET /api/serverconf/ HTTP/1.1", host: "localhost:8060"
我的nginx配置文件如下所示:
worker_processes 4;
events { worker_connections 1024; }
http {
server {
listen 8060;
#listen [::]:80 ipv6only=on;
#access_log ../logs/access.log upstreamlog;
#return 301 https://$host$request_uri;
}
server {
#listen 443 ssl http2 default_server;
#listen [::]:443 ssl http2 default_server;
ssl_certificate ../cert.pem;
ssl_certificate_key ../cert.key;
location /api/serverconf/{
proxy_set_header Accept-Encoding "";
# proxy_pass http://localhost:4000/api/serverconf/;
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-Proto $scheme;
}
}
upstream backend {
#zone dotnet 64k;
ip_hash;
server localhost:4000;
#server localhost:8081;
#server localhost:8082;
#server localhost:5000;
}
}
主要目标是创建一个负载平衡的应用程序。我该如何解决该问题,或者这种方法是否适用于Nginx服务器?
预先感谢