locked
Subfolder - reverse proxy RRS feed

  • Question

  • User-1480303302 posted

    Hi to all.
    My MVC application hosted on abc.mydomain.com hosted on server1.
    I have domain newdomain.com and I want do use subfolder (newdomain.com/abc), that redirects to abc.mydomain.com.
    Can this be done?
    Idea is when client access newdomain.com/abc with browser, redirection is made to abc.mydomain.com.

    I’m using reverse proxy on server 2:
    ProxyPass “/abc” “http://abc.mydomain.com/“ ProxyPassReverse “/abc” “http://abc.mydomain.com”
    Wednesday, December 12, 2018 6:26 PM

All replies

  • User503812343 posted

    whenever requests or Action method executed for newdomain.com/abc redirect it to  abc.mydomain.com using permanent link.

    public ActionResult Redirect()
    {
         return new PermanentRedirectResult ("http://abc.mydomain.com");
    }


     

    Wednesday, December 12, 2018 7:05 PM
  • User-1480303302 posted
    Everywhere in application I'm using application root "~".
    ("~/Content/cssBundle", "~/Scripts/scriptsBundle", "~/Content/img" etc.)
    When I'm hosting application on http://abc.mydomain.com, everything is
    fine, but on newdomain.com/abc, browser searches files on
    newdomain.com/Content, instead of newdomain.com/abc/Content.
    Probably the solution is to use absolute url, insted of application root.
    Maybe instead of
    bundles.Add(new ScriptBundle("~/Scripts/coreScriptsBundle").Include
    (
    "~/Scripts/jquery-2.0.3.js",
    "~/Scripts/jquery.unobtrusive-ajax.js",
    "~/Scripts/jquery.number.js",
    "~/Scripts/bootstrap.min.js",
    ));
    i should use
    bundles.Add(new
    ScriptBundle("http://abc.mydomain.com/Scripts/coreScriptsBundle").Include
    (
    "~/Scripts/jquery-2.0.3.js",
    "~/Scripts/jquery.unobtrusive-ajax.js",
    "~/Scripts/jquery.number.js",
    "~/Scripts/bootstrap.min.js",
    ));

    and insted of
    app.UseCookieAuthentication(new CookieAuthenticationOptions
    {
    AuthenticationType =
    DefaultAuthenticationTypes.ApplicationCookie,
    LoginPath = new PathString("/Account/Login")
    });
    I should use
    app.UseCookieAuthentication(new CookieAuthenticationOptions
    {
    AuthenticationType =
    DefaultAuthenticationTypes.ApplicationCookie,
    LoginPath = new
    PathString("http://abc.mydomain.com/Account/Login")
    });

    but it's not working....
    Wednesday, December 12, 2018 7:59 PM
  • User503812343 posted

    your issue is creating bundle or rendering bundle

    When you run your application are you able to browse through browser http://abc.mydomain.com/Scripts/coreScriptsBundle?. If not means problem is in creating bundle 

    If rendering is the issue try

    @Scripts.Render("~/Content/bundlename")



    Wednesday, December 12, 2018 8:29 PM
  • User-1480303302 posted

    Working perfect on abc.mydomain.com
    Wednesday, December 12, 2018 8:41 PM
  • User-474980206 posted

    your reverse proxy needs to edit the response html and change the imbedded urls to add the "/abc". most proxy servers have regex support to do this. 

    another option is to make sure all urls are relative to the requesting page. this will require writing your own url handler to use instead of Url.Action, and Url.Content, and of course the implicit "~/" support.

    a final option is to duplicate your site on the primary server in subfolder "/abc". then the proxy is just domain to domain (you can use a host header or port to make a separate site).

    Friday, December 14, 2018 4:27 PM