SAP Commerce Cloud platform doesn't integrate CDN solution. For small business, we have what we call Web Caching. This cache is limited up to 5GB and 120 IPOS. But for larger business, it is often necessary to invest in true CDN solution as Akamai or CloudFlare.
CDN can server many purpose as
This article is focusing on proxy and static caching
SAP Commerce Cloud Portal has a limitation on number of EndPoints it can support. Above 50 EndPoints, performance will be impacted drastically.
The solution is to setup CDN in upstream to act as proxy.
Public domain name is pointing on CDN server. All user requests are going through CDN even if it is not cached. CDN is used as Proxy to have one EndPoint declaration in SAP Commerce Cloud Portal. This EndPoint should accepts only requests coming from CDN. IP Filtering can be setup in EndPoint to restrict access to out coming IP of CDN.
CDN must inject X-Forwarded-Host HTTP header to inform SAP Commerce Cloud which website content should be rendered.
In Legacy Accelerator, this HTTP Header is captured by Tomcat. And in Composable Storefront / Headless, this HTTP Header is captured by NodeJS / SSR part.
In Legacy situation, we've to push customize Tomcat server.xml setting into SAP Commerce Cloud system.
SAP Commerce Cloud is using server.xml.tmpl template file to generate sever.xml target file. You should first download server.xml.tmpl content from HAC by Groovy Script. Then, you have to update the content according the change suggest in below. And finally, you must encode the content in base64 to inject the new server.xml.tmpl into SAP Commerce Cloud deployment system.
properties / Cloud Portal
ccv2.file.override.70.content=<base64Encoding>
ccv2.file.override.70.path=/opt/startup/server.xml.tmpl
server.xml
className="org.apache.catalina.valves.RemoteIpValve"
hostHeader="x-forwarded-host"
portHeader="x-forwarded-port"
protocolHeader="x-forwarded-proto"
Then, it is necessary to customize CMSSiteFilter.java / cmsSiteFilter bean to include a logic for fetching domain name provided by Tomcat and matching this domain name with URL Patterns defined in CMSSite item.
currentdomain = httpRequest.getServerName();
At the end, domain mapping can be processed as we have direct public domain name request (URL Patterns).
In Headless situation, we've nothing to configure. Composable Storefront is supporting natively X-Forwarded-Host HTTP header.
core-libs/setup/ssr/express-utils/express-request-origin.ts
// domain name provided by HTTP Header is taken when it has been set
export function getRequestOrigin(req: Request): string {
[...]
let forwardedHost = req.get('X-Forwarded-Host');
[...]
return `${req.protocol}://${forwardedHost}`;
server.ts
// here X-Forwarded-Host is treated by Angular system
server.engine(
'html',
ngExpressEngine({
bootstrap: AppServerModule,
})
);
Because CDN has been setup in upstream, SAP Commerce doesn't receive anymore user IP. And then OpenSearch log won't contain correct RemoteAddr.
"loggerFqcn":"org.apache.logging.slf4j.Log4jLogger",
"contextMap":{"RemoteAddr":"[111.222.333.444] "
If you want to continue track user IP until SAP Commerce / Tomcat system, you've to setup X-Forwarded-For HTTP header in CDN system.
CDN integration can be a complex topic. We see here only small part on what CDN can do and how we can integrate with SAP Commerce Cloud. For more advance scenario, you can contact SAP Expert Services
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |