ヘルプ

1

Sitemap generating with IP instead of Domain

Avatar
Levi Bensley

I have noticed my website is every now and again generating the sitemap with the IP instead of the domain.

Should be...


https://www.domain.co.uk/contact-us

But it is sometimes get rendered like this

https://1.1.1.1:8069/contact-us

The server is using Nginx as a reverse proxy


アバター
破棄
2回答
1
Avatar
oodo-odoo
Best Answer

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 :)

アバター
破棄
0
Avatar
Kim Asplund
Best Answer

In: Settings - Technical - System parameters - web.base.url

do you have that set to your domain? if not thats probably the issue.

2コメント
アバター
破棄
Avatar
Levi Bensley
-

Yes this set to the right address.

Not sure if Nginx could also cause an issue

Avatar
oodo-odoo
-

I have debugged a similar issue. Seems like cache poisoning due to misconfiguration of nginx. I will paste it as an answer (basically a copy/paste from an answer I written in another topic but it gives some better understanding.