Just adding this here as it probably explains the situation for anyone else hitting this:
The problem is probably due to your nginx/apache config. You likely set the X-Forwarded-Host header with var $host. That is ok in most situations. However it means that nginx/apache will use the fqdn in the request from the client and will copy it over to the Odoo backend. E.g. your site is available through example\.com \(your\ "main"\ site\)\ and\ example2\.com \.\ You\ test\ it\ by\ using\ example\.com/sitemap\.xml and\ all\ is\ well\.\ A\ few\ hours/days\ later\ the\ sitemap\ is\ requested\ through\ example2\.com/sitemap\.xml \(e\.g\.\ google\ crawler\)\ and\ now\ the\ temporarily\ generated\ sitemap\ will\ have\ example2\.com in\ it\.
Set\ the\ proxy\ variables\ correctly\ in\ your apache\ configuration\ and\ it\ will\ go\ from\ http\ to\ https\ and\ also\ have\ the\ correct\ domain\ in\ the\ sitemap\.
If\ you\ make\ a\ change\ make\ sure\ to\ delete\ the\ sitemap\-\*\.xml\ in\ the\ ir\.attachments\ \(Settings,\ Technical,\ Attachments\)\ so\ it\ gets\ regenerated\.\ Yes\ this\ is\ nowhere\ mentioned\ that\ the\ sitemap\ is\ regenerated\ from\ time\ to\ time\ and\ nobody\ seems\ to\ be\ able\ to\ point\ this\ out\.\ Nor\ is\ there\ any\ mention\ on\ the\ frequency\ of\ this\ or\ the\ mechanism\ that\ triggers\ it\.
You'd\ need\ these\ settings\ in\ apache\ vhost:
RequestHeader\ set\ X\-Forwarded\-Proto\ https
RequestHeader\ set\ X\-Forwarded\-Host\ example\.com
ProxyPreserveHost\ On
ProxyRequests\ Off
So\ here\ you\ have\ the\ explicit\ example.com passed to Odoo.
You might ask: how was my website reachable through this strange domain name: apache/nginx misconfiguration. E.g. the default site pointing to your Odoo install. Another misconfiguration can be setting ProxyRequests On in Apache. A similar setting will exist for nginx but having this enabled allows requests for any site to go through your Nginx and if your Odoo install is the default site it will send that request fqdn to Odoo and that one will be used in the backend. Do NOT enable ProxyRequests unless you know exactly what you're doing or if you want cache-poisoning (hint: you don't want this).
Hope this helps someone else wasting plenty of time :)
Hi,
I have the same problem, did you manage to solve it?