ASP.Net Core Reverse Proxy with different root -
i having problems proxying asp.net core mvc app.
my mvc app running on kestrel on localhost:5000 , apache 2.4 reverse proxy running on localhost:80
i want proxy requests localhost:80/test localhost:5000
here httpd.conf part proxy:
... <location "/test"> proxypass "http://localhost:5000" proxypassreverse "http://localhost:5000" </location> ...
the proxy works, links broken. if have anchor links controller named homecontroller action about, link returned proxy localhost/home/about instead of localhost/test/home/about. host correct, it's context root test missing.
what best practice handle ? configuration in asp.net core specify context root taghelpers take account ? or configuration in apache proxypass rewrite links (really not big fan of this) ?
thanks!
there usepathbasemiddleware temporarily adds base path middleware system, various services can deal path prefix.
you can activate using usepathbaseextensions.usepathbase
extension method. call method first thing in startup’s configure
method base path want use.
in case, this:
public void configure(iapplicationbuilder app) { app.usepathbase("/test"); // other middleware app.usestaticfiles(); app.usemvc(); // … }
note usepathbasemiddleware not prevent application working without prefix. can use both , without base path, , correctly adapt.
note may need adjust authentication providers if depend on external providers need callback path. in case, need make sure proper path being configured there.
Comments
Post a Comment