js-ipfs
js-ipfs copied to clipboard
feat: act as HTTP PROXY for http://<cidv1b32>.ipfs.localhost
PoC right now, but you get the idea.
⨎ curl -v --proxy 'http://127.0.0.1:8180' 'http://bafybeih4mncb4apdnrvbnqkicldf74sfstykoryzi7noaf4njxkiuflnay.ipfs.localhost/658.png' > 658.png
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8180 (#0)
> GET http://bafybeih4mncb4apdnrvbnqkicldf74sfstykoryzi7noaf4njxkiuflnay.ipfs.localhost/658.png HTTP/1.1
> Host: bafybeih4mncb4apdnrvbnqkicldf74sfstykoryzi7noaf4njxkiuflnay.ipfs.localhost
> User-Agent: curl/7.54.0
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 OK
< content-type: application/octet-stream
< cache-control: no-cache
< Date: Fri, 12 Jul 2019 14:20:44 GMT
< Connection: keep-alive
< Transfer-Encoding: chunked
<
{ [16211 bytes data]
100 853k 0 853k 0 0 30.0M 0 --:--:-- --:--:-- --:--:-- 30.8M
* Connection #0 to host 127.0.0.1 left intact
refs https://github.com/ipfs/go-ipfs/issues/5982
License: MIT Signed-off-by: Alan Shaw [email protected]
Really cool! While we are at it, would be cool to implement DNSLink and Subdomain gateway too (#2248). HTTP proxy mode (https://github.com/ipfs/js-ipfs/issues/1877) is a cherry on top :cherries:
Thank you so much for opening this PR and for your patience in getting it merged. js-ipfs is being deprecated in favor of Helia. You can https://github.com/ipfs/js-ipfs/issues/4336 and read the migration guide.
This has largely been superseded by https://specs.ipfs.tech/http-gateways/path-gateway/ - any changes should be suggested as IPIPs to the spec.