Serve your Heroku app via HTTP/2 and QUIC protocols
In this example we are going to deploy to Heroku a simple NodeJS CRUD app rendered via Caddy proxy which provides SSL termination and supports HTTP/2 and QUIC protocols. QUIC protocol is like “HTTP/2 over UDP”. It’s experimental but is already used by Google when you visit Gmail and Google Drive in your Chrome browser.
Deploying to Heroku
First checkout the repo and deploy it to Herokung git push
. Make sure the app is available via *.herokuapp.com
URL:
$ git clone https://github.com/dockhero/quic-protocol-demo.git
$ cd quic-protocol-demo
$ heroku create
$ git push heroku master
$ heroku open
Then install Dockhero addon and the CLI plugin:
$ heroku addons:create dockhero
$ heroku plugins:install dockhero
This will spin up a dedicated EC2 instance with Docker installed. As the provisioning happens, take a minute to look at dockhero-compose.yml in the root of the repository:
version: "2"
services:
proxy:
image: dockhero/caddy-proxy
ports:
- "80:80"
- "80:80/udp"
- "443:443"
- "443:443/udp"
volumes:
- caddy_certificates:/srv
environment:
VIRTUAL_HOST: ${DOCKHERO_HOST}
TARGET_URL: ${HEROKU_APP_URL}
volumes:
caddy_certificates:
driver: local
The only service defined there is Caddy proxy. It’s configured to send all incoming traffic to TARGET_URL
(see corresponding Caddyfile in Github). During startup it also generates a trusted SSL certificate via Let’s Encrypt service — that’s why the stack includes a volume to store the certificates, to ensure it does not request them at every startup. Another important point is the use of DOCKHERO_HOST
and HEROKU_APP_URL
variables. They are set automatically by Dockhero.
Now you are ready to launch the stack described by dockhero-compose.yml
heroku dh:compose up -d
and check the logs with
heroku logs --tail -p dockhero
If everything went fine, you should be able to see your app available at Dockhero URL:
heroku dh:open
This command will launch your default browser pointing to the stack launched in Dockhero. To verify the protocol being used, install HTTP/2 and SPDY indicator extension from Chrome Web Store
You may need to enable QUIC protocol support in Chrome in order to test QUIC protocol
PS: If you followed the steps above, you will probably see an empty JSON on your screen. You can populate it with date using CURL — just put proper URL into the command below:
curl -H "Content-Type: application/json" -X POST -d '{"name":"Kitty","species":"cat"}' https://vital-sun-4864.dockhero.io/pets
Originally published at docs.dockhero.io.