Search code examples
node.jssslnginxproxyweinre

How to configure weinre behind Nginx proxy?


I have the latest weinre installed (2.0.0-pre-I0Z7U9OV). I can start it, all is working fine, but I need to run it behind a Nginx Proxy to be able to use a trusted SSL Certificate. So what I tried is the following:

upstream weinre {
    server 127.0.0.1:8080;
}

server {
...
    location /weinre/ {
        proxy_pass       http://weinre/;
        proxy_set_header Host $host;
    }
}

The site is opening, all fine, but when adding the target script to my mobile page, I can't see it appear in the targets list. So I started to dig into it and found the follwing in the Chrome console:

POST https://domain.net/ws/target 404 (Not Found)

Why is it POSTing to ws/target and not weinre/ws/target? Since everything else is working under the weinre sublocation.

Is it even possible to run weinre under such setup?


Solution

  • Not quite sure what's going on there; what is the URL of the of the target script you are embedding in your page? It's possible to override the URL of the weinre server, instead of having it calculated from the target script, by setting the global window.WeinreServerURL, as you can see in the Target.coffee file. You can see how the server URL is used to get the URL to the "socket" URL here.