What 'https with certificate' local test server do others use?

Background

I developed backup and restore for my app.

While testing I found that it was difficult to persuade some browsers to access files for the restore process.

I decided to tackle the browser trust issue before investigating other causes — that is, to install the app with a manifest, which in turn requires https, which in turn requires a TLS certificate that browsers will fully trust (no challenge).

What I’ve tried

I discovered caddy: “The Ultimate Server with Automatic HTTPS

Very promising. But it also entailed learning how to start/stop/etc stuff with systemd’s systemctl. So I’m learning two things and making slow progress.

My question

What do other people use for a ‘browsers think they’re getting this app from a properly certificated https server’ test environment?

Do I persevere with caddy, or is there an easier way?

Just to be clear. You’re currently using Caddy for testing during development but to set it up you’re installing it globally and having to use systemd to manage it’s lifecycle?

I’m using fiddler classic as a proxy and just set up one simple url rewrite rule. I can then convert any https url like https://localhost or even Microsoft.com to actually hit http://localhost:3000 . This makes the browser think its on the real page so you can even use the regular oauth redirect url. A bonus is that this also works for any Device on your network. this is a great way to Connect iPads or phones directly to your dev server receiving live updates on code save. Just add your proxy server in wifi settings. Really nice to quickly get a feel of the size and how touch control work side by side of the pc screen.

Thank you @dwayne, the implication in your question made me laugh :smiley:

I’m currently trying to use caddy. It was advice on their forum and, as I discovered later, in the documentation, that said manage it using systemd.

Thank you @Atlewee, that sounds good but, from a brief web search, it appears the free version is Windows only — I develop on Ubuntu.

I use localias for these purposes. It maps ports to local addresses that end with ‘.local’ and the browser accepts the HTTPS connection. Hope it works for you!

1 Like

Actually, I wasn’t trying to imply anything. I really was trying to understand your exact situation. However, from your response, what I described does seem to be the case.

I have also used Caddy in some of my projects. I did it via either Devbox or Nix flakes but I never used the HTTPS support. I used it to serve my SPA locally.

No need to use systemd. Everything is scoped to your project.

Thank you, @timinou

Looking at the github pages for localias: it’s running caddy :slightly_smiling_face: …but it does all the setting up for you :grinning_face:

Why don’t you use something like https://packetriot.com/ or https://ngrok.com/ ?

This makes it pretty easy to run the software locally but also have it exposed to the Internet with HTTPS. I personally prefer Packetriot.

Or doesn’t this work in your case?

@dwayne, I thought you were suggesting that it wasn’t a good idea to run something like caddy globally :slightly_smiling_face:

It’s interesting that you say,

My understanding is that modern browsers are suspicious of anything not served https with a valid TLS certificate. So to test locally under real-world conditions requires these.

Thank you for the heads-up on Devbox — Microsoft and cloud-based :slightly_frowning_face: — and Nix flakes — another learning curve :face_with_diagonal_mouth:


Thank you @mywzQxMJ76.

Firstly, I guess, because I’ve never heard of them :laughing:

I’m not looking for run-local/expose-global, or to put anything online yet. I just want to persuade locally run browsers that my locally hosted app is coming from a TLS-signed, https served source, so that the app and browser behave exactly as they will when the app is online.

So far, running caddy via localias is the front runner…

My experience has been that (mobile) Firefox works fine on http://localhost, but (mobile) Chrome will not preserve secure cookies on that scheme/domain, which breaks my site

Well, the ability to access the app globally is just a side effect, I simply use Packetriot to avoid CORS issues or to test realistically.

However, when you finally run your software on a machine using Caddy that would probably be the best test setup.

That’s the wrong Devbox you’re looking at. It’s this one: Devbox: Portable, Isolated Dev Environments. It’s open source, based on Nix, and works locally. It doesn’t have the steep learning curve of Nix and Nix flakes.

caddy seems like a good option, maybe is possible to just run the binary $ caddy at least with nginx that is possible.

There is also a bunch free of services to create tunnels to remote servers providing a subdomain and an SSL certificate, useful for testing Oauth, where a valid domain is required.

$ cloudflared tunnel --url http://localhost:3000
$ ngrok http 3000 --domain=myapp.example.com

This will of course expose a local server, and that might not be always desirable, claudeflare tunnel, ngrok and others are free, but they require installing a binary. Its also possible to use ssh to make a reverse tunnel and map a port in running nginx… too complicated.
But this little service seems very cool, no deps!

$ ssh -p 443 -R0:localhost:8080 qr@free.pinggy.io
$ curl https://myapp.a.pinggy.link # :) 

Maybe I’m looking at this too simply, but here is where my head goes. If I understand your situation, you want to run locally and serve over https. There is no need to expose the URL on the internet.

The simplest approach might be to:

  1. Create yourself a Certificate Authority cert
  2. Sign a cert with that certificate authority for your webserver
  3. Install the CA on your local system as an authorized CA
  4. Configure your webserver to use your cert (any webserver that supports https will do - many in node, or use Caddy, etc.)
  5. Serve your app through the webserver

There are lots of tutorials on how to generate a CA on linux and how to generate a cert with this CA.

Hopefully I’m not misunderstanding things… :wink:

This can be expanded to support others on your local net just by sending them your CA and having them authorize it locally on their systems.