Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Wes 6 posts 86 karma points
    Dec 02, 2022 @ 00:02
    Wes
    0

    Multisite, load balancing and the Preview function

    I have 2 sites with 1 backend setup on Azure as follows:

    scalable app service plan frontend1.com frontend2.com

    non-scalable App service plan backend.com

    I've locked the front-ends so users only access the admin via backend.com but the issue is - how do setup the admin so users can use the preview function because preview will always go to backend.com.au and not frontend1.com?

    Thanks!

  • Conor Howe 36 posts 137 karma points
    Dec 03, 2022 @ 16:32
    Conor Howe
    0

    If I understand this correctly, this would be the desired functionality.

    The two front-end servers are subscribers and will only show the published content. With the preview functionality you will want to be looking at non-published content or changes etc before you publish to the front-end servers, so this would be done within the back-end or admin server

    If I have misunderstood the question let me know :)

  • Wes 6 posts 86 karma points
    Dec 05, 2022 @ 04:07
    Wes
    0

    You've understood exactly correctly :)

  • Conor Howe 36 posts 137 karma points
    Dec 05, 2022 @ 07:21
    Conor Howe
    0

    Brilliant, everything should be as it seems then. Just make sure you've done the roles described here also:

    https://docs.umbraco.com/umbraco-cms/fundamentals/setup/server-setup/load-balancing#scheduling-and-server-role-election

    We normally choose to do this manually 😄

  • Wes 6 posts 86 karma points
    Dec 06, 2022 @ 12:26
    Wes
    0

    Ok maybe I didn't explain clearly enough, the issue that we've got is that this is multi-site. As an example:

    frontend-1.com has it's own web app and frontend-2.com has it's own web app

    We use the siteURL to determine which what we need display

    My CMS users will only access umbraco via backend.com.

    When they click 'save and preview' this goes to backend.com so I don't understand how we can show them what a page looks like for 'frontend-1.com' because we can't use the siteURL to select the appropriate CSS/JS etc.

    Hopefully that makes sense?

  • Chris Norwood 131 posts 642 karma points
    Dec 07, 2022 @ 09:40
    Chris Norwood
    0

    We have a set up that sounds similar - we have 4 sites (the www site, 2 subdomains and a site that's not a subdomain - another www site - but is part of the same collection) that are all in a single Umbraco installation.

    In our case 3 of them share a master page and one of them has its own dedicated master layout, so JS/CSS etc. are loaded there, using relative URLs; however we have 2 servers which only serve one of the subdomains (an Intranet) and 2 that serve the other 3 sites.

    When a page is previewed in Umbraco in the back office it uses the ID of the document:

    [backendaddress]/umbraco/preview/?id=1076

    If your 2 front-end sites are both in the same DB (which it sounds like they must be) and have separate Master pages, as long as the JS/CSS etc. are relative they'll be loaded correctly.

    If you're somehow using the site URL as a way of deciding which files to load in code, the Umbraco preview will indeed know nothing about that and it won't work; if you have separate master layout files for the individual sites then everything should be fine (as long as the JS/CSS files you need exist on the back office server where the code is expecting to find them).

  • Wes 6 posts 86 karma points
    Dec 08, 2022 @ 00:59
    Wes
    0

    Thanks :) That's pretty much that situation we're in.

    Wondering whether there's a way to keep preview available on my front-end sites then update the 'save and preview' button so it uses the full path URL of the page?

  • Chris Norwood 131 posts 642 karma points
    Dec 08, 2022 @ 15:40
    Chris Norwood
    0

    I don't think you can have Preview available on the front-end site if they're on a different server as you'd have to be logged into the Umbraco back office (which you shouldn't do on a subscriber server, and assuming you're explicitly setting the front-end servers as subscribers then they won't show you the up-to-date content as it's not published yet).

    I think you'd need some kind of plug-in, or a way of replacing the "save and preview" link (or detecting when it's clicked/a preview is being generated) so that when it's clicked it looks at the ID of the page being requested, maybe grabs it via the Umbraco helper, decides which site it's in and then runs the relevant code.

    From what you've said above it sounds like these 2 sites share a Master.cshmtl file and decide which JS/CSS to load based on the requested URL (and therefore must share document types/templates etc) - if that's the case then I think you can probably just use the Model.URL in the Master view instead of the request URL?

    Something like (this is very basic and if you have different cultures you'll need to allow for that):

    var theUrl = Model.Url(null, UrlMode.Absolute); //now make decisions based on the URL of the Model, which won't be the Preview URL 
    

    (Edit: if you find you really need to know that you're view a page in preview mode you should be able to do it like this):

    if(Context.Request.Cookies.ContainsKey("UMB_PREVIEW")) 
    { 
    //actions to take in preview mode on back office server here 
    }
    

    Hope that helps! :)

Please Sign in or register to post replies

Write your reply to:

Draft