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?
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 :)
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.
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).
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?
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
}
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!
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 :)
You've understood exactly correctly :)
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 😄
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?
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).
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?
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):
(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):
Hope that helps! :)
is working on a reply...