Welcome! Log In Create A New Profile

Advanced

ASP.NET MVC routing with NGINX proxy

Posted by jorgen 
ASP.NET MVC routing with NGINX proxy
February 07, 2017 12:03PM
I have an .Net Core (MVC 6) web application running on Linux machine via Kestrel, with NGINX serving as proxy from port 80 -> 5000 Unfortunately I´m not allowed to use default route as another application has priority, both have to run over port 80, meaning requests are forwarded like:

127.0.0.1 -> another app

127.0.0.1/conf -> my app

And in NGINX config file it's defined as:

location /conf {
proxy_pass http://127.0.0.1:5000;
proxy_cache_bypass $http_upgrade;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 32 4k;
}

The thing is, if I run application using standard location ( location / ) , routing of MVC app runs fine. But having /conf appended to location simply breaks MVC routing, because application continues to return routes that are based on root location, without /conf prefix. So after user gets to default landing page, all routes (links, actions) are still pointing to address like 127.0.0.1/Home/About instead of 127.0.0.1/conf/Home/About - and to make it even worse, these links (/conf/Home/About) are not working either.

Any suggestions on how should I proceed in solving this ? Is there some NGINX-based solution or I'll have to figure some alternative on app level ?

Thanks in forward !
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 322
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready