ipfs-webui icon indicating copy to clipboard operation
ipfs-webui copied to clipboard

Post request Failure with Nginx reverse proxy

Open akimoto72738 opened this issue 1 year ago • 7 comments

I use Nginx as a reverse proxy for the IPFS API interface with the domain name api.mydomain.com, and it works well. However, the EXPLORE page(only) is not functioning properly. I have identified that the browser still use 127.0.0.1:5001 for POST requests in this page. How should I configure it to make the browser use https://api.mydomain.com/ for POST requests?

image

Here is my config about api

"Addresses": { "API": "/dns4/api.mydomain.com/tcp/5001", "Announce": [], "AppendAnnounce": [], "Gateway": [ "/dns4/gateway.mydomain.com/tcp/443", "/ip4/0.0.0.0/tcp/8080" ],

other page is normal image

updated: I return the webui version to [v3.0.0],then the problem resolved XD (before is 4.1.1 latest)

akimoto72738 avatar Nov 27 '23 03:11 akimoto72738

@SgtPooki looks like there is a bug in the kubo-rpc-client migration, initial investigation makes me believe: https://github.com/ipfs/ipfs-webui/blob/v4.1.1/src/bundles/ipfs-provider.js#L389 should be:

loadHttpClientModule: () => create(apiAddress),

kubo-rpc-client expects: https://github.com/ipfs/js-kubo-rpc-client/tree/master#importing-the-module-and-usage and the ipfs-provider expects a promise: https://github.com/ipfs-shipyard/ipfs-provider/blob/4bde75366e79799c330c63a6c4ed96746402aca1/src/providers/http-client.js#L23

This might fix this, however this would require a setup like @akimoto72738 has to test.

whizzzkid avatar Nov 30 '23 05:11 whizzzkid

@akimoto72738 you should be able to do localStorage.setItem('apiOpts', JSON.stringify({})) to configure your endpoint for the explore page.

However, this will be changing when I fix https://github.com/ipfs/ipfs-webui/issues/2176 shortly, and you'll need to do localStorage.setItem('kuboGateway', JSON.stringify({port: '1337'}))

https://github.com/ipfs/ipld-explorer-components/blob/edd95a4bd4c12fb55f0815ebbe18847f65f84823/src/bundles/helia.ts#L74

SgtPooki avatar Nov 30 '23 07:11 SgtPooki

kubo-rpc-client expects: ipfs/js-kubo-rpc-client@master#importing-the-module-and-usage and the ipfs-provider expects a promise: ipfs-shipyard/ipfs-provider@4bde753/src/providers/http-client.js#L23

@whizzzkid I'm going to be getting rid of ipfs-provider since it's another one of those very old and unmaintained packages.

SgtPooki avatar Nov 30 '23 07:11 SgtPooki

Yes, I felt so, ipfs-provider can prolly be deprecated.

whizzzkid avatar Nov 30 '23 15:11 whizzzkid

Hi @SgtPooki , I have listed most of the fields in localStorage for your investigation, I dont know what value for apiOpts, I just copy and paste localStorage.setItem('apiOpts', JSON.stringify({})), is something url&port like value of IpfsApi ?

image image

and here is my api setting in webui interface

image

@whizzzkid thanks If it's confirmed that this issue is a bug, you can @ me for testing after it's fixed. I usually keep my WebUI version as up-to-date as possible with your latest releases

@akimoto72738 you should be able to do localStorage.setItem('apiOpts', JSON.stringify({})) to configure your endpoint for the explore page.

However, this will be changing when I fix #2176 shortly, and you'll need to do localStorage.setItem('kuboGateway', JSON.stringify({port: '1337'}))

https://github.com/ipfs/ipld-explorer-components/blob/edd95a4bd4c12fb55f0815ebbe18847f65f84823/src/bundles/helia.ts#L74

akimoto72738 avatar Dec 01 '23 07:12 akimoto72738

@akimoto72738 currently, the apiOpts is for webui to talk to the Kubo RPC API, and kuboGateway is for talking to the kubo daemon as a trustless-gateway. You can set them both to unblock yourself, but I'll take your comments as a need to look into normalizing these fields again.

Ideally, we should be able to infer the kuboGateway from the apiOpts in ipfs-webui.

PS.. the latest ipfs-webui supports the kuboGateway now. In IPFS-Desktop, and webui.ipfs.io, and dev.webui.ipfs.io

SgtPooki avatar Dec 06 '23 09:12 SgtPooki

One more thing. your original question was

How should I configure it to make the browser use api.mydomain.com for POST requests?

You should run the following in your browser console: localStorage.setItem('kuboGateway', JSON.stringify({port: '80', host: 'api.mydomain.com'}))

you should be able to verify the same functionality at explore.ipld.io (which is a web version of the explore page)

SgtPooki avatar Dec 06 '23 09:12 SgtPooki