←back to thread

I can see your local web servers

(http.jameshfisher.com)
652 points jamesfisher | 1 comments | | HN request time: 0.211s | source
Show context
suyash ◴[] No.20028417[source]
Can anyone share what measures we can take as web developers to secure local development environment?
replies(3): >>20028730 #>>20028771 #>>20029113 #
deno ◴[] No.20028771[source]
Custom DNS server with DNS rebind protection. E.g. if you’re running OpenWRT you’re fine[1].

Also just don’t test on localhost. You can use a proper domain (or claim one in .test TLD[1] if you’re fine with selfsigned certs) and point it to localhost.

If you’re going to use any redirect flow like OAuth/OpenID you’re going to need this for testing eventually anyway.

[1] https://openwrt.org/docs/guide-user/base-system/dhcp

[2] https://en.wikipedia.org/wiki/.test

replies(2): >>20029429 #>>20034016 #
asdkhadsj ◴[] No.20029429[source]
What do you recommend if you're running a local server? Eg, I've developed programs before with the assumption that the user will be running it either for their local machine, or perhaps for their local network.

Think self hosted Wiki/etc. I was never sure (and thusly have yet to properly implement it) what would be secure, but also a good UX. A normal auth + self signed https would be simplest I imagine, but I'm not clear if browsers widely accept that. I recall Sandstorm having issues with this area, and required a domain to fully run properly. Which seems.. complex for a minimal install requirement.

Thoughts?

replies(1): >>20030849 #
1. deno ◴[] No.20030849[source]
I actually wanted to do something similar one time and I figured there’s one way to do it:

1) Get a domain name for the project, e.g. mycoolwiki.tld

2) In the installer/setup provision for the user a random subdomain, e.g. d2c8116f19d0.mycoolwiki.tld

3) Use Let’s Encrypt DNS method to provision cert

4) Redirect d2c8116f19d0.mycoolwiki.tld to LAN IP

It’s not ideal because you need some external infrastructure and it assumes no DNS rebind protection.

However, if your webapp has a client and server, that is communicates via API only, you can actually do a lot better:

4) Setup local server to accept CORS requests from d2c8116f19d0.mycoolwiki.net only

5) Host client at d2c8116f19d0.mycoolwiki.tld

Additionally,

6) Make the client a PWA with offline support

and/or

6) Offer browser extension to use local copy of the client when user visits ∗.mycoolwiki.tld

Though for my use case I actually wanted to have ∗.mycoolwiki.tld/ipfs/<hash> be backed by IPFS and offer generic extension that both verifies that the IPFS gateway is playing nice and (if configured) redirect to local gateway.

Also offering Electron client instead of browser would work as well and saves you getting the cert.