prestaconcept / PrestaSitemapBundle

A symfony bundle that provides tools to build a rich application sitemap. The main goals are : simple, no databases, various namespace (eg. google image), respect constraints etc.
MIT License
355 stars 102 forks source link

Use specific base_url in dynamic sitemap #263

Closed nkl-kst closed 3 years ago

nkl-kst commented 3 years ago

Hi,

we are using your bundle and it works great, but we are facing a (more or less) small problem: Our app runs behind a proxy, so the URLs generated in the sitemaps are based on the IP adress of the proxy. This happens because the app doesn't know that it's not the user who made the (proxied) request.

Is there any way to use a specific host for URLs in sitemaps, like we can do it with the --base_url=http://example.com parameter when dumping the sitemaps? I didn't find anything neither in the documentation nor in the code.

For now we dump the sitemap with the mentioned --base-url param. But if the dump is not available for some reason, the on-demand generated sitemap will have the URLs with IP adresses inside again.

Thanks for your help.

yann-eugone commented 3 years ago

Hi @nkl-kst !

Thank you for using this bundle :)

Maybe the problem you are facing has something to do with request context : https://github.com/prestaconcept/PrestaSitemapBundle/blob/master/Resources/doc/2-configuration.md#configuring-your-application-base-url https://symfony.com/blog/new-in-symfony-5-1-simpler-request-context

Or with proxy configuration : https://symfony.com/doc/current/deployment/proxies.html

Does it help ?

nkl-kst commented 3 years ago

Thanks for your response, Yann.

As far as I know, the content of your first two links only apply if we are using the dumper, where no request context is available. But we like to change the base_url when generating the sitemap on demand, where the request context and the base_url are already available.

We will have a closer look at the proxy configuration options, as we did not know the possibility to define the http headers where the client request informations are stored. Thanks for sharing this one!