Sitename different than hostname in docker setup

Hi,

I have a strange problem and can’t find the correct solution. Even not when reading the source code. Maybe somebody can help me here:

So far so got. This setting is working as expected and I see the login-screen. But when I look in the logfiles, I have always the following error message from the socketio container (when performing api/method/frappe.realtimeget_user_info) :

    Error: getaddrinfo ENOTFOUND site1.local
     at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26) {
   errno: -3008,
   code: 'ENOTFOUND',
   syscall: 'getaddrinfo',
   hostname: 'site1.local',
   response: undefined
 }

Somehow socketio doesn’t recognize the correct hostname.

The following thins I checked so far:

  • When I check socketio.js, then I find the get_url method which is used for this request. This one uses socket.request.headers.origin to determine the url.

  • In erpnext_nginx service/container, the origin header is set to $http_host

  • therefore I set the http_host header as well in my reverse proxy but I still don’t get socketio fixed
    → No changes

  • change socket.request.headers.origin to socket.request.headers.referer works as expected
    → But I don’t know, if this is correct?

Somehow I don’t have a clue why socketio doesn’t use the real hostname.

Is there some external configuration possible?

Bets regards,
–thomas

Reply to myself:
I think, the referer was a good starting point to fix that issue. After some more research I found that I was able to modify the default.conf.template in the erpnext-nginx container.

Maybe @revant_one: As you are the master of the docker images :smiley: :
May I ask you if this suggestion would be anything meaningful? If yes, I’ll open a new pull request to fix this one:

In the file default.conf.template in the erpnext-nginx container I found the following line of code in the section of socketio:

proxy_set_header Origin $scheme://$http_host;

If i change that on my local environment to

proxy_set_header Origin $http_referer

I’m able to work with socketio without any issues. Is there any reason why there is $schema and $http_host mentioned? If not, I would suggest do change this to $http_referer to get rid of the restriction to deploy ERPNext with a sitename other than the host-name of the application server.

Thx and best regards,
–thomas

1 Like

I started with nginx.conf from frappe/bench source.

Removed the SSL part from it.

Later there was also a contribution Changed X-Frappe-Site-Name header to use value from `$host` instead o… by girip11 · Pull Request #184 · frappe/frappe_docker · GitHub

Do send a PR. I’ll try it out locally. We can take discussion on PR.

:+1: See you on the other side :smiley:
https://github.com/frappe/frappe_docker/issues/231