How to enable fastify's http2 in Digital Ocean app platform
Asked Answered
S

2

6

I'm trying to figure out how to enable http2 for my rest api. I uses fastify as its server and according to their documentation secure http2 can be enabled in the following way

https://www.fastify.io/docs/latest/Reference/HTTP2/

The issue I am facing now is that this api is deployed to https://www.digitalocean.com/products/app-platform on multiple server instances (for reliability and scalability)

If I understand correctly trafic is routed to these instances through cloudflare, its set up for you out of the box. I assume cloudflare also manages all ssl certificates in this case.

Thus my question, how can I specify certificate files to fastify (those .key and .cert ones) in this setup? I don't have access to cloudflare account as it is managed by Digital Ocean.

Simitar answered 31/3, 2021 at 11:36 Comment(1)
Currently facing the same issueSelfseeker
E
1

According to the DigitalOcean App Platform documentation, it appears that you can only enable HTTPS for custom domains, and not for the default app platform domain (your-app.ondigitalocean.app).

https://docs.digitalocean.com/products/app-platform/quickstart/#register-a-custom-domain

If you want to enable HTTPS for your app, you will need to add a custom domain, and then add an SSL certificate for that domain.

https://docs.digitalocean.com/products/networking/load-balancers/how-to/manage/#ssl

According to the Fastify documentation, in order to enable HTTPS/HTTP2, you will need to specify the key and cert files in the options object when initializing the Fastify server.

https://www.fastify.io/docs/latest/Reference/HTTP2/#http2

Since you do not have access to Cloudflare, you could use Lets Encrypt to get a SSL Cert.

Elliotelliott answered 17/5, 2022 at 16:19 Comment(0)
A
0

One of the most common ways for activating SSL and HTTPS is using let's encrypt and certbot.In order to do that follow this steps in your clouds SHELL:

sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-nginx
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

# Only valid for 90 days, test the renewal process with
certbot renew --dry-run

Also check this reference it was useful for me. CHECK

Amylose answered 23/5, 2022 at 14:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.