Decode in nginx natively
Opened this issue · 2 comments
Deleted user commented
For ipns.name I've looked into what's available for nginx and I think we can do the decode step completely within nginx, which I presume will make it much more robust and performant.
- https://github.com/openresty/set-misc-nginx-module#installation
- set_base32_alphabet abcdefghijklmnopqrstuvwxyz234567
- set_base32_padding off
- set_decode_base32 $hash $hshcaFromHttpHost
- rewrite (/.*) /ipns/$hash(\1)
What do you think? I'm going to give it a try as soon as I find a bit of time.
kyledrake commented
I use the set misc module on my proxy servers for re-encoding URIs, I just put this in for testing:
set_base32_alphabet abcdefghijklmnopqrstuvwxyz234567;
set_base32_padding off;
set_decode_base32 $hash $subdomain;
rewrite (/.*) https://ipfs.io/ipfs/$hash(\1);
The problem here is that this leaves you with the multihash ($hash) in binary format, and the misc module doesn't have a base58 encoder. Your options here are base32, base64, hex, or writing a base58 implementation for that module.
Deleted user commented
Mh you're right, thanks for giving it a try. What we could do though is add support for hshca in multihash.