Try ERPNext Buy Support Partners Foundation

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:

  • I’m using the official docker images from https://github.com/frappe/frappe_docker - version 11
  • With those I’m setting up a new ERPNext instance.
  • As site name I use: site1.local
  • In my docker environment I have a reverse proxy in front of all my applications (traefik)
  • This reverse-proxy listens to my public URL and overwrites the header “HOST” with “site1.local”.
  • So I can access ERPNext trough my public hostname and the reverse proxy forwards the correct header to ERPNext.

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 https://github.com/frappe/frappe_docker/pull/184

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

:+1: See you on the other side :smiley: