question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Accessing the webui behind a proxy

See original GitHub issue

Hi, I have a server with my basic webapp being served via nginx.

Now I have installed ipfs and want to add a /ipfsui proxy target which would take me to the webui for ipfs, thus I made the following additions to my existing fowardproxy in nginx.conf

        location /ipfsui {
            proxy_pass http://127.0.0.1:5001/webui/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }

        location /ipfs {
            proxy_pass http://127.0.0.1:5001;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }    

Now I can go to the ipfs ui by going to http://my_server_ip/ipfsui which properly redirects me to http://my_server_ip/ipfs/hash_here/#/

However, the page has no relevant ipfs info (like my peer id and so on).

Then I went on to inspect the console error messages and found:

Uncaught TypeError: Cannot read property 'split' of undefined     bundle.js:2185
(anonymous function) @ bundle.js:2185
(anonymous function) @ bundle.js:21711
EventEmitter.emit @ bundle.js:6430
Response.handle @ bundle.js:7115
xhr.onreadystatechange @ bundle.js:6878
bundle.js:2225 Object {version: undefined, updateAvailable: false, updating: false, gateway: "http://127.0.0.1:8080"}

After looking up these error lines I came to the conclusion that the code in page.jsx (which has since changed in the main webui git repo, link: https://github.com/ipfs/webui/blob/master/js/views/page.jsx, but not changed so as it would overcome this problem of mine) determines the ipfs api url and port from window.location.host and window.location.port.

This is the snippet of the webapp that that I currently get served (via ipfs of course):

var host = window.location.hostname
var port = window.location.port || 80
var daemonConf = LocalStorage.get('daemon')
if (daemonConf) {
  host = daemonConf.host
  port = daemonConf.port
}
var ipfs = require('ipfs-api')(host, port)
var ipfsHost = window.location.host

var Page = React.createClass({
  displayName: 'Page',
  getInitialState: function () {
    var t = this

    ipfs.config.get('Addresses.Gateway', function (err, res) {
      if (err || !res) return console.error(err)

      var split = res.Value.split('/')
      var port = split[4]

(you can see where the code failed to split and tracedback from this snippet and the error above)

I know that not everyone will be running this behind a proxy and also that I can temp fix via making the ipfs api listen on 0.0.0.0 by setting it via ipfs config ... but want to ask if there is anby other way to get around my current problem before I embark on that path.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:4
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
zertrincommented, Sep 27, 2016

My current workaround without opening to the world the port from the server where ipfs is running is using SSH port forwarding like this:

ssh -L 5001:localhost:5001 myserver.example.org

and then accessing from my computer at http://localhost:5001/webui

It’s working but still looking to avoid having to open a SSH connection and using a reverse proxy.

5reactions
wrouesnelcommented, Oct 8, 2016

There’s also problems if you’re trying to put HTTPS in front of the UI via nginx. It loads fine, but then the web-ui immediately tries to access it’s own content via HTTP rather then HTTPS and is blocked.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Accessing the webui behind a proxy · Issue #95 · ipfs ... - GitHub
wrote: Hi, I have a server with my basice webapp being served via nginx. Now I have installed ipfs and want to add...
Read more >
Accessing WebUI located behind a proxy - Web API - Forums
I've installed the WebUI and the PC with uTorrent and the UI appears correctly when I access it using http://127.0.0.1:34500/gui. However, if I ......
Read more >
[SOLVED] Accessing webui locally and behind a reverse proxy
Found the solution. Be sure to append slashes in the proxy statements. SSLProxyEngine on SSLProxyCheckPeerName off SSLProxyCheckPeerCN off
Read more >
CLI: Web UI and Web Proxy
Configuring web UI · certificate <certificate> – Specify the certificate to use. · country <country> – Type your country code. · state <state>...
Read more >
Accessing the Big-IP webUI may not work correctly through a ...
This can be caused by a proxy between the administrative user and the Big-IP. Cause. The webUI periodically queries the big-IP using REST...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found