Home > database >  Configure NGINX with Asp.Net Core Application Reverse Proxy as SubFolder like IIS
Configure NGINX with Asp.Net Core Application Reverse Proxy as SubFolder like IIS

Time:11-16

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

But in IIS, i can configure my application to access like this: http://localhost/name.of.app/

And IIS exposes the application over IP, like this: http://192.168.x.x/name.of.app/

The only way i find to work in NGINX is like above:

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

What i need to do in this hell to configure and work like IIS?

Thanks in advance.

CodePudding user response:

Problem solved. In NGINX use: location /appname

and in asp.net add app.UsePathBase("/appname");

  • Related