[英]Ngnix not matching location adress
I have problem with Nginx +.Net core.我对 Nginx +.Net 内核有疑问。 I'm using default nginx configuration on only location block with "/" any other location blocks like "/api" doesn't works.
我只在带有“/”的位置块上使用默认的 nginx 配置,任何其他位置块(如“/api”)都不起作用。 Here is my configuration file
这是我的配置文件
location /api{
proxy_pass https://localhost:5002/api/;
}
location /auth
{
proxy_pass https://localhost:5002/auth/;
}
location /
{
proxy_pass https://localhost:5002/; #home adress of spa app
}
This is because you are specifying a URI at the end of the proxy pass which means the location will be appended to the URI as well.这是因为您在代理传递的末尾指定了一个 URI,这意味着该位置也将附加到 URI。 Check this examples:
检查这个例子:
www.site.com/api -> http://localhost:5002/api/api
www.site.com/auth -> http://localhost:5002/auth/auth
Instead, don't provide the URI in the locations so the path matches.相反,不要在位置中提供 URI,以便路径匹配。 Like this:
像这样:
location /api {
proxy_pass http://localhost:5002;
}
location /auth {
proxy_pass http://localhost:5002;
}
location / {
proxy_pass https://localhost:5002/; #home adress of spa app
}
So now the URI ends up like this.所以现在 URI 就这样结束了。
www.site.com/api -> http://localhost:5002/api/
www.site.com/auth -> http://localhost:5002/auth
PD.- check the https:// schema in your locations, do you really need it? PD.- 检查您所在位置的 https:// 架构,您真的需要它吗? Use http, I don't think you have SSL enabled for that port.
使用 http,我认为您没有为该端口启用 SSL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.