Recently we got requirement to host a site in our AEM environment.The site will be always static with few image ,css and js .
We got the html file along with the other required contents (images, css, js fonts etc).
We are planning to create a directory inside "/opt/communique/dispatcher/cache/content" called "newsite"
/opt/communique/dispatcher/cache/content/newsite ,so that it serves from the dispatcher cache always.
Any idea how can we achieve this.When i hit the newsite.html it does not load the images .
Also is there any other easy way to host this static site in AEM dispatcher.
Have you already built a site in AEM or outside AEM?
Where is it hosted - in AEM or outside AEM?
Does AEM dispatcher talk to AEM publish server for fetching the content and is it configured per Adobe's recommended guidelines?
We have already build our primary sites e.g abc.com , xyz.ca in AEM which is as per Adobe's recommended guideline.
Now we have a new requirement to host one static site "qwe.com" in AEM. And for this we really don't want to put anything in author and publisher side.Just want to put the static files(html,css,js,and fonts) in dispatcher layer.Is this possible?
Or please suggest any other suitable workaround.
If you want to serve content statically then you will have to configure something like this for site configurations on paths that you don't want to be served by the dispatcher-handler:
Technically, this is possible but may not be recommended due to various reasons if you plan to use the same domain for both AEM served content and static content served by web server. This static content would not be managed by Dispatcher in any way but by the web server. You may setup virtual domains/sub-domains or similar solutions based on your requirement.
Follow the best practices/security considerations for each module.
Rather than mounting dispatcher on root ('/'), mount it on a specific pattern for AEM served content and let some other path say /foo to be statically served by apache or do the vice versa using lookahead regex.
Based on you AEM site's dispatcher design, you would need to test that there are no issues in caching/flushing/generation of stat files for the dispatcher managed/mounted path.
Have a separate CI/CD pipeline to compile/transpile/package/deploy your static code into the web server.
Another solution for this would be to have multiple virtual hosts within Apache. Each virtual host would have its own separate document root. Avoid nested the sites within each other folder structure. The static site will reside in one location and the site serving content from AEM will be in a separate location. Just make sure the Dispatcher configuration manage content in one location.
We have created the virtual hosts /var/www/html/newsite/newsite.html
And add below configuration in httpd.conf.As soon as we added this now AEM contents are not serving getting 404.Because By default, all requests are taken from this directory /var/www/html.
Any idea how can we separate both traffic.
Assuming that you're asking for how to setup virtual host config--
set up one for dispatcher served content and other for apache served content
<VirtualHost *:80> ServerName branda.com DocumentRoot /usr/lib/apache/httpd-2.4.3/htdocs/content/sitea <Directory /usr/lib/apache/httpd-2.4.3/htdocs/content/sitea> <IfModule disp_apache2.c> SetHandler dispatcher-handler ModMimeUsePathInfo On </IfModule> Options FollowSymLinks AllowOverride None </Directory> </VirtualHost>
Keep separate docroots & directory paths
DocumentRoot /usr/lib/apache/httpd-2.4.3/htdocs/content/sitea and
DocumentRoot /usr/lib/apache/httpd-2.4.3/htdocs/content/siteb and
If you plan to use the same shared location "/var/www/html" as mentioned in my above post, then use <Location> or <LocationMatch> tags
We have configured the site bit different way.We put the contents (html,image and assets css js etc) inside
And created a softlink of newsite folder in ur docroot and configure the rewrite rule in httpd.conf accordingly .Its working fine.
Thanks all for your suggestion.