DEV Community

Cover image for How to test https on localhost with help of Caddy
Arpit Kumar
Arpit Kumar

Posted on

How to test https on localhost with help of Caddy

In this post I am going to talk about testing https on localhost. Testing https on localhost is difficult of ssl certificates issue.

If you want to test integration of https cookies, public webhooks etc you need https enabled web endpoint. Also any browser based https flows become difficult while testing on localhost.

Today we are going to use an awesome open source tool Caddyserver.

Assuming we are running a server at localhost:3000

To use CaddyServer with reverse proxy to port 3000 for HTTPS on localhost, follow these steps:
Find install instructions for Caddy on - https://caddyserver.com/docs/install
Once installed open up a terminal and run below command

caddy reverse-proxy --to :3000

CaddyServer will generate a self-signed certificate for localhost and enable HTTPS on port 443.

To access the HTTPS version of your localhost website, enter https://localhost in your web browser. CaddyServer will reverse proxy all requests to port 3000.

Top comments (0)