Enable SXG Origin Trial on HTTP Gateway
lidel opened this issue · comments
For a wider IPFS context on Signed HTTP Exchanges and WebPackage
see parent issue ipfs/in-web-browsers#121 and ipfs/in-web-browsers#121 (comment)A good TL;DR on current SXG Origin Trial is in this post at developers.google.com.
Summary
b2 implementation snapshot of SXG is supported by Google Chrome 71 as a part of opt-in Origin Trial.
We've received token from Google Chrome Team for use on ipfs.io
.
(via https://bit.ly/OriginTrialSignup)
Remaining work is to set our gateway to return it with every /ipfs/*.sxg
Required HTTP Headers
To participate, these headers should be returned with every .sxg
file returned by our gateway:
Content-Type: application/signed-exchange;v=b2
Origin-Trial: AoNMhcfAN9G0rKV6+fmRdoU2UfSaFadhfjSq0QJYB1yNP+f8sM6Rz0SmQNNBbVkJOzIQ3MwLzef4YaJ/ZpBOUQwAAABeeyJvcmlnaW4iOiJodHRwczovL2lwZnMuaW86NDQzIiwiZmVhdHVyZSI6IlNpZ25lZEhUVFBFeGNoYW5nZU9yaWdpblRyaWFsIiwiZXhwaXJ5IjoxNTQ1MjczODI3fQ==
In other words, we need something along these lines (nginx pseudocode, probably needs refinement):
location ~ ^/ipfs/.*\.sxg$ {
proxy_hide_header Content-Type;
add_header Content-Type "application/signed-exchange;v=b2";
add_header Origin-Trial "AoNMhcfAN9G0rKV6+fmRdoU2UfSaFadhfjSq0QJYB1yNP+f8sM6Rz0SmQNNBbVkJOzIQ3MwLzef4YaJ/ZpBOUQwAAABeeyJvcmlnaW4iOiJodHRwczovL2lwZnMuaW86NDQzIiwiZmVhdHVyZSI6IlNpZ25lZEhUVFBFeGNoYW5nZU9yaWdpblRyaWFsIiwiZXhwaXJ5IjoxNTQ1MjczODI3fQ==";
proxy_pass http://127.0.0.1:8080;
}
References
- Signed HTTP Exchanges: Chrome Origin Trials (living document)
- Origin Trials Guide for Web Developers
- Origin Trial Token Validator (to ensure token is correct and did not expire yet):
- Test resources for b2 implementation snapshot of the
Signed HTTP Exchanges from web-platform-tests/wpt/signed-exchange: QmVnnXjwXyEKhnrC1L7wegepUum2zN4JZUgtvA7DYtj4rG - Reference implementation of Signed HTTP Exchanges format generator
hey @mburns any news on this?
fyi Origin-Trial
token listed above expires on 2018-12-20. We will probably need to switch to a new one after that date – when you add it to gateway config keep in mind it should be easy to find/configure/toggle this value.
Update: this just landed! ❤️
Headers are in place (current Origin-Trial
token valid until 2018-12-22
):
$ curl -s -I -X GET https://ipfs.io/ipfs/QmVnnXjwXyEKhnrC1L7wegepUum2zN4JZUgtvA7DYtj4rG/sxg-location.sxg | egrep -i '(Content-Type|Origin-Trial)'
Content-Type: application/signed-exchange;v=b2
Origin-Trial: AoNMhcfAN9G0rKV6+fmRdoU2UfSaFadhfjSq0QJYB1yNP+f8sM6Rz0SmQNNBbVkJOzIQ3MwLzef4YaJ/ZpBOUQwAAABeeyJvcmlnaW4iOiJodHRwczovL2lwZnMuaW86NDQzIiwiZmVhdHVyZSI6IlNpZ25lZEhUVFBFeGNoYW5nZU9yaWdpblRyaWFsIiwiZXhwaXJ5IjoxNTQ1MjczODI3fQ==
I smoke-tested it in Chrome 71 – works as expected:
- Open sample file from https://ipfs.io/ipfs/QmVnnXjwXyEKhnrC1L7wegepUum2zN4JZUgtvA7DYtj4rG/sxg-location.sxg in Chrome 71
- You will see Origin provided by SXG:
Thanks!
Anyone interested in this, follow ipfs/in-web-browsers#121