amppackager
amppackager copied to clipboard
Example golang proxy script
I'm looking into the amppackager to see if I can get signed exchanges going for a project with static html files. I am able to use amppackager locally over port 8080.
To do test on a cloud server (with Go) I was hoping to also find an example script that would show how to proxy (locally) requests correctly. I'm not well versed in Go, so having this should help out tremendously.
request -> server <-> index.go
Are there any resources for this? I found this but sure stuff is missing (correct vary header, etc.)
https://github.com/ampproject/amp-by-example/blob/master/backend/packager.go
This doesn't exactly match your request, but perhaps it will still be useful as a reference. Here is an example of a site running in quasi-production mode: https://gist.github.com/mattwomple/17d361ec876e8e275196762273c4d1ba
nginx is used as the front-end server, proxying requests to amppkg
as needed. It only lacks a valid certificate with the CanSignHttpExchanges
extension; see information about the -invalidcert
flag here (master branch, not yet in releases).
Thanks @mattwomple! If that example turns out to be helpful to others, we may want to link to it from the README somewhere. FWIW, https://amppackageexample.com/ is using a similar nginx setup.
Yeah, our recommended architecture assumes you already have a TLS server serving your content, and suggests to put amppkg
behind it. As a result, we don't recommend one in particular. Should we? Either way, it would be nice to have examples for other popular servers, like Apache and IIS.
It also sounds like we could expand our docker dir with an example TLS server, along with instructions on how to hook the two together. (Swarm? Kubernetes? OpenShift? I'm unfamiliar with the space currently.) This is generically tracked in #114 but no work on it yet.
@ymschaap not sure if this is what you’re after but there’s some rough patches to amppackager to make it support packaging static files here that might be useful to you: https://github.com/ampproject/amppackager/pull/183
Yes, #114 seems like a smart ticket to prioritise. Choosing at least a whole Docker setup with serving static files, or as an independent Golang setup.
Adding Nginx in the stack, might be confusing but could be useful. I did found this resource:
https://github.com/Warashi/try-amppackager
#183 uses App Engine, which is not part of my stack.
My case, I have the signed certificate, I have build static files, but stuck with adding the moving parts together in a simple deploy
example.