slimerjs icon indicating copy to clipboard operation
slimerjs copied to clipboard

Webserver always binds to localhost

Open ghost opened this issue 10 years ago • 10 comments

I found this bug when I'm trying to set up a render service. Look into src/components/httpd.js line 502, "localhost" is always be used whatever you set. I change it to '0.0.0.0' and service works correctly.

ghost avatar Apr 22 '14 07:04 ghost

More bug: When I bind server to 0.0.0.0 means I expect the server to receive all incoming requests, but in components/httpd.js line 1546, if the server ip of current request context didn't add to identity, the scheme check will be failed and of course for ip 0.0.0.0.

ghost avatar Apr 22 '14 10:04 ghost

The httpd.js component has been extracted from the Mozilla repository.

Note for myself: see if it is included in recent version of Firefox/Xulrunner (in the addons sdk?)

laurentj avatar Jun 13 '14 07:06 laurentj

So how do i make this work then exactly?

seiflotfy avatar Jul 23 '14 09:07 seiflotfy

using "0.0.0.0" into httpd.js does not work on my machine.

A solution would be to retrieve all Ip interfaces and add them into the http server identity. However it seems there is no such Gecko API to retrieve them.

For the moment, the workaround is to indicate the ip/hostname to webserver.listen():

var webserver = require("webserver").create();
webserver.listen("192.168.1.1:8083", function(request, response) {
...
});

laurentj avatar Jul 23 '14 12:07 laurentj

yeah that does no work for me. I changed the ip to reflect y ip on the network and it does not work. only works if i call it via localhost

On Wed, Jul 23, 2014 at 2:42 PM, Laurent Jouanneau <[email protected]

wrote:

using "0.0.0.0" into httpd.js does not work on my machine.

A solution would be to retrieve all Ip interfaces and add them into the http server identity. However it seems there is no such Gecko API to retrieve them.

For the moment, the workaround is to indicate the ip/hostname to webserver.listen():

var webserver = require("webserver").create(); webserver.listen("192.168.1.1:8083", function(request, response) { ... });

— Reply to this email directly or view it on GitHub https://github.com/laurentj/slimerjs/issues/179#issuecomment-49867955.

seiflotfy avatar Jul 23 '14 13:07 seiflotfy

Seems this is in the add-ons SDK: http://mxr.mozilla.org/mozilla-central/source/addon-sdk/source/lib/sdk/test/httpd.js (but note the "stability": "experimental" status)

hallvors avatar Jul 23 '14 13:07 hallvors

@hallvors I don't call directly this version. I had to hack httpd.js to fix some behavior... The original file is http://mxr.mozilla.org/mozilla-central/source/netwerk/test/httpserver/httpd.js and the SlimerJS version one is src/components/httpd.js

laurentj avatar Jul 23 '14 13:07 laurentj

Whoa, I saw your fix on v0.9 and it works. When is v0.9.2 due? Thanks again... Mozilla webcompat team will be psyched :)

On Wed, Jul 23, 2014 at 3:30 PM, Laurent Jouanneau <[email protected]

wrote:

@hallvors https://github.com/hallvors I don't call directly this version. I had to hack httpd.js to fix some behavior... The original file is http://mxr.mozilla.org/mozilla-central/source/netwerk/test/httpserver/httpd.js and the SlimerJS version one is src/components/httpd.js

— Reply to this email directly or view it on GitHub https://github.com/laurentj/slimerjs/issues/179#issuecomment-49873218.

seiflotfy avatar Jul 23 '14 14:07 seiflotfy

On 0.9.6, when I try to bind to 10.0.0.2, and use netstat -lntp, it shows:

$ sudo ip netns exec robots netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:8500            0.0.0.0:*               LISTEN      1565/xulrunner
tcp        0      0 0.0.0.0:8501            0.0.0.0:*               LISTEN      1564/xulrunner

I believe it should be showing 10.0.0.2 not 0.0.0.0. Why is 0.9.6 interpreting 10.0.0.2 and probably any non 127.0.0.1 ip as 0.0.0.0?

CMCDragonkai avatar Oct 19 '15 12:10 CMCDragonkai

when connecting through a proxy, the proxy ip must be specified...

untoreh avatar Aug 29 '16 14:08 untoreh