简体   繁体   English

将 NGINX 与 Asp.Net Core 应用程序反向代理配置为子文件夹,如 IIS

[英]Configure NGINX with Asp.Net Core Application Reverse Proxy as SubFolder like IIS

I'm trying to configure NGINX as Reverse Proxy like the official microsoft tutorial: https://docs.microsoft.com/pt-br/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-5.0我正在尝试像微软官方教程一样将 NGINX 配置为反向代理: https ://docs.microsoft.com/pt-br/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-5.0

But in IIS, i can configure my application to access like this: http://localhost/name.of.app/但是在 IIS 中,我可以将我的应用程序配置为这样访问:http://localhost/name.of.app/

And IIS exposes the application over IP, like this: http://192.168.xx/name.of.app/ IIS 通过 IP 公开应用程序,如下所示: http://192.168.xx/name.of.app/

The only way i find to work in NGINX is like above:我发现在 NGINX 中工作的唯一方法是:

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name   appname.*;
    index     index;
    location / {
        proxy_pass         http://127.0.0.1:5000;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection keep-alive;
        proxy_set_header   Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
    }
}

But in this way, the application:但是这样,应用程序:

  1. Not exposed external不暴露在外
  2. Url is like this: http://appname.localhost网址是这样的: http://appname.localhost

What i need to do in this hell to configure and work like IIS?我需要在这个地狱中做什么才能像 IIS 一样配置和工作?

Thanks in advance.提前致谢。

Problem solved.问题解决了。 In NGINX use: location /appname在 NGINX 中使用: location /appname

and in asp.net add app.UsePathBase("/appname");并在 asp.net 添加app.UsePathBase("/appname");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM