Static site hosting
This guide will show you how to host a static site using the File Store DXP Service. The guide will walk you through the prerequisites, the steps to host a static site, and how to access the site.
Prerequisites
These are the prerequisites to host a static site using the File Store DXP Service. They must be completed before proceeding with the steps to host a static site.
- Feature Flags
-
Check that Squiz Support has enabled the following feature flags in your Squiz DXP instance:
-
Digital Asset Management
-
Static Site Hosting
-
File Store
-
- Content Management domains setup
-
Ensure that you have the domain setup in Squiz Content Management that you want to use to host the static site. If you want both the domain’s www and non-www versions to work, you must set up both domains in Content Management.
Contact Squiz Support for assistance with this configuration task.
- Enable static hosting on domains
-
Static hosting must be enabled for the domains you want to host the static site. Check if this configuration is in place by viewing the Service settings and noting whether the Enable static hosting on this domain option is selected.
Contact Squiz Support for assistance with this configuration task if necessary.
About static site file resolution
The resolution flow for files hosted in the static site is as follows:
-
If the URL matches a file in the mapped folder, that file is served.
-
If the URL matches a folder in the mapped folder, the
index.html
file is served. -
If the URL does not match a file or folder (or the
index.html
file does not exist), a404.html
file from the root of the mapped folder is served. -
If the
404.html
file does not exist, the request is forwarded to the Squiz Content Management instance to which the domain is linked.
Mapping a folder to a domain or sub-folder
To begin hosting a static site, you need to map a folder from the File Store service to a domain or a sub-folder. Doing so lets you access the static site from that selection.
Before you start
-
As described in Usage guidelines and recommendations, mappings are domain specific. If you want both to work, you need to follow these steps on both the www and non-www versions of the domain.
-
The static site will be accessible from the domain or sub-folder and will overwrite any existing content.
Steps
To map a folder to a domain or sub-folder:
-
In your Squiz DXP organization home page, click the
card. -
Open the Mappings page and click the site for which you want to manage mappings.
-
Click the card to edit mappings for any domains with static hosting enabled.
-
Select the repository path you want to map on the Edit route dialog box.
-
Click Save to map the repository path to the domain.
-
Check back in a few minutes to ensure the mappings are available because mapping may take a few minutes to become available.
Populating the static site content
To populate the static site content, you must upload the files to the folder you mapped to the domain or sub-folder.
File Store supports archive files (specifically .tar
files).
You can create a compressed archive of your static site and then expand the archive into a mapped folder to deploy your static site.
Uploading files can be done through the REST API or the File Store UI.
Before you start
-
Read the Usage Guidelines for large files to understand the file size requirements and limits for the service.
-
Remember that for File Store to serve a file from a static site, the file must:
-
have public permissions set on it in the File Store.
-
have returned a safe status when scanned by the virus scanner.
-
Steps
To prepare a static site directory for upload to the File Store:
-
Create a tarball of the directory you want to upload.
tar czf [name_of_archive_file.tar] []name_of_directory_to_tar]
For example,
tar czf public static-site-example
-
Using the File Store UI or the Large file process endpoint, upload the archive to the root of your File Store directory.
-
Create an empty folder to expand the uploaded
tar
into. -
Extract the
tar
file in your created folder using the Extract option. -
Select the empty directory you created.
-
Click Extract to begin the extraction process.
-
After the files are extracted, verify that all files:
-
Have the virus scanner icon present to indicate they are safe.
-
Have got Public file permissions set.
-
Accessing the Static Site
After the files have been uploaded to the folder, you can access the static site from the domain or sub-folder to which you have mapped the folder.
Troubleshooting
If the static site is not accessible, check the following configuration areas:
- Does the domain have static hosting enabled?
-
Check the Service settings page.
- Are the mappings set up correctly?
-
Check the
page. - Have the files been uploaded to the correct folder?
-
Check that the folder contains all the required files using the File Store UI.
- Do all files have public permissions set on them?
-
Check the file permissions in the File Store UI.
- Have all files been scanned by the virus scanner and have returned a safe status?
-
Check the virus scanner status icon in the File Store UI.