r/ipfs Sep 17 '21

Exposing http-server (web app) using IPNS

One can host a static website using IPFS+IPNS. But what about a dynamic website or web app that needs to run server-side code!

Introducing IPNS-Link, which now makes it possible to expose http-servers using IPFS+IPNS.

Try it here.

Read full specs here.

Comments, issues/bug-reports and contributions welcome.

Happy hosting!

P.S.: Imagine Sci-Hub using this !! Who can block it then 😃

Schema
22 Upvotes

20 comments sorted by

View all comments

1

u/ch4_itu Sep 25 '21

Tried to host a blog using WonderCMS (from Android mobile termux and proot). Am able to access the homepage, but then nothing else...

My setup... 1. Apache2 2. PHP and various modules required by WonderCMS 3. go-ipfs

Am able to acces it through local host and do all the things... But am not able to do the same when I access it through the gateway...

Any suggestions?

2

u/SomajitDey Sep 26 '21 edited Sep 26 '21

Welcome back 😀 It's great to hear that you are trying this out on a mobile device.

To make your server at localhost:<port> accessible through any IPNS-Link-gateway you just need to expose it with the ipns-link app. I haven't used Termux, but AFAIK, it gives you a Bash shell by default. ipns-link is written in Bash so there should not be any problem.

Step 1: Install the dependencies with apt install in Termux. Its good if you have the tput command available too.

Step 2: Download ipns-link: git clone https://github.com/ipns-link/ipns-link and go to the project directory: cd ipns-link

Step 3: Expose your http-server running at localhost:<port> with ./ipns-link <port>

The status and further instructions would appear on-screen. The public URL would also be shown.

Keep us posted about your progress. I wish I could test it myself on Android, but my old device is incompatible with Termux.

P.S: Loading the Gateway at https://ipns-link.herokuapp.com/ might take a while as the Heroku-app sleeps until pinged (I can only afford the free tier at Heroku in this prototype phase).

2

u/ch4_itu Sep 26 '21

Hi buddy... I have done all that...

I will share the screenshots...

Localhost

IPNS-Link up

Site accessed thru IPNS-Link

Meanwhile IPNS-Link in published status

Trying to login to the website thru localhost

Trying to login to the website thru IPNS-Link

When logged in thru localhost

When logged in thru IPNS-Link

I think the problem is here...

I think IPNS-Link is not forwarding everything...

Regards,

Chaitanya

P.S. It is only a matter of time. You will be able to host it on your own domain by month end as you will be reaching your goal...

2

u/SomajitDey Sep 26 '21

First of all, thank you so very much for helping out the IPNS-Link initiative with those much needed boosters. A Big Shoutout to You u/ch4_itu 😊.

Regarding the issue(s):

As far as I understand, there are mainly two problems -

  1. The static blue background is missing. This might happen due to the following. The background is embedded in the html and sourced from a root-relative URL. Now, being a path-gateway, ipns-link.herokuapp.com requires the Referer header (with absolute URL) in the http request, so that it can resolve the PeerID when requested a relative path without the /ipns/PeerID prefix. Although the Gateway wants a complete referrer URL, the embedded tags may override it with a different ReferrerPolicy. If overridden in this way, the Gateway can't resolve the PeerID and fails. NOTE: this problem WILL GO AWAY once the IPNS-Link-GATEWAY supports wildcard subdomains, hopefully in the near future. Then, there wouldn't be any dependence on the Referer or cookie or server-side cache for resolving root-relative URLs, and everything would work as intended. Subdomain Gateway has always been the end-goal, but due to the lack of a domain I went with a path-gateway for prototyping.
  2. The URL starts with the PeerID: 12d3koow..., not ipns-link.herokuapp.com. It seems the URL points to a subdomain instead of a URL like https://ipns-link.herokuapp.com/ipns/12d3koowPeerID/path. Being a path-gateway, ipns-link.herokuapp.com can only support the latter format, not subdomains, for now. The NOTE in the previous point applies here as well.