-
Notifications
You must be signed in to change notification settings - Fork 298
ipfs behind proxy #581
Comments
Hi @sjeeva, I'm not sure if I understand your question, but let me try to answer it and you tell me what I missed. When you create an ipfsAPi instance with Does this answer your question? What is the |
Opps!! few details where missing due to github formatting... How do we translate |
@sjeeva should be |
@sjeeva I see, you want to hit a path so that it gets routed in nginx. Wanna add support for that specific feature to this module? |
@diasdavid, yes.. if you give me a few pointer in the code, I can work on this feature... |
The parsing happens here -- https://github.com/ipfs/js-ipfs-api/blob/master/src/index.js#L9-L44 --, you should just have to test for the multiaddr + path case and break it to host (including path) + port respectively. |
Hey @diasdavid and @sjeeva I have deployed IPFS behind a proxy and I have analyzed this problem. Basically, the problem is in this line. There is a default port defined by getConfig. As a consequence, when I agree that we should have a default port value, but it blocks this use cases. I was thinking on a possible solution for identifying when we should set the default port. try {
const maddr = multiaddr(hostOrMultiaddr).nodeAddress()
config.host = maddr.address
config.port = maddr.port
} catch (e) {
if (typeof hostOrMultiaddr === 'string') {
config.host = hostOrMultiaddr
config.port = port && typeof port !== 'object' ? port : config.port
}
} If the received parameter is not in the multiaddr format, the catch code will be executed. Here, we have to decide wether to use the default port or not. I cannot find any good solution for solving this maintaining the default value, when the received hostname is not a } catch (e) {
if (typeof hostOrMultiaddr === 'string') {
config.host = hostOrMultiaddr
if (hostOrMultiaddr.indexOf(':') > -1 || !port || typeof port === 'object' ) ){
config.port = undefined
} else {
config.port = port
}
}
} What are your thoughts? Should I advance with this solution? |
There seems to be two issues here. First is how js-ipfs-api handles traditional strings, those are fine to fix for now (I have no opinion on the specific implementation). But the general plan is to move everything to multiaddrs, which means we should also be able to support paths in The question |
Thanks for your analyze @victorbjelkholm Regarding the For the |
@sjeeva you can use const IpfsApi = require('ipfs-api')
const ipfs = IpfsApi({
protocol: 'http',
host: '<IPAddress>',
port: 80,
'api-path': '/ipfs/api/v0'
}) Let me know if you have any other probs. |
I am running my IPFS behind an ngnix proxy and redirected port 5001 of IPFS to
http://<IPAddress>/ipfs
We are developing a Web Interface from which we want to access
http://<IPAddress>/ipfs
, however js-ipfs-api supports ipfsAPI which seems to be accepting only IP address / port as shown belowvar ipfs = ipfsAPI(
'ip4/<IPAddress>/tcp/5001'
, {protocol: 'http'})Is there any option that would allow me to connect to
http://<IPAddress>/ipfs
using ipfsAPI?The text was updated successfully, but these errors were encountered: