enonic / app-metafields

SEO Meta Fields app for Enonic XP
https://market.enonic.com/vendors/enonic/com.enonic.app.metafields
Apache License 2.0
0 stars 9 forks source link

Support custom domain for meta-data #113

Closed Bellfalasch closed 8 months ago

Bellfalasch commented 1 year ago

In Sitemap.xml version 1.5.0 you landed a tiny but brilliant feature: "support custom domain". Could this also be added to this app, SEO Metafields?

The problem is today we run all apps in Kubernetes and Azure, and each app running are served from a very long and obscure domain. Using any portal or content function will generate a xxx-apps-int.io-like URL even if the domain we visit the page on is gjensidige.no. So all apps using type:absolute will give the "wrong" URL, and we cannot control this. So what we do for sitemap and SEO output is we hack this to fix it: we run filters on the generated html response, and replace all xxx-apps-int.io with the correct URL. Before sitemap.xml 1.5 we had two filters for this in total, running on all our requests, so with 1.5 we can now remove one of them. If this domain-feature also landed in the SEO app we could remove the last filter!

As far as I recall, only canonical URL output, and one of the og: outputs use absolute as type and those are affected here.

sigdestad commented 9 months ago

Hi Bobby!

Question, are you generating your responses based on "live requests" i.e. someone requests www.domain.com -> lotsofstuff -> k8s - and then when you request generation of an absolute URL, and in the response, you get "k8s.obscure.stuff/path/to/item"?

The solution to this problem is to enable host forwarding in your infrastructure. This is a fairly standard proxy/loadbalancer/webserver setup. Basically, the proxies should either forward the host header, or set x-forwarded-host: www.domain.com. Then XP will generate the correct URLs for you. NB! Same goes for protocol, so XP will generate https rather than http in the absolute urls.

In apache for instance, this is enabled adding this line to a vhost: ProxyPreserveHost On

sigdestad commented 9 months ago

The protocol is forwarded as x-forwarded-proto if i remember correctly