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.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay