How can I define multiple hostname on local for PHP development purpose?

Not extreme use case really, HTTPS default is the way of the internet, so to replicate production usage, it is common sense to replicate HTTPS usage on dev environment too.

If the domain names used aren’t valid domains and only for local dev testing, you can override both server and your PC’s DNS using /etc/hosts file on server and equivalent on your PC depending on OS. That is what I did at Caddy V2 tls internal only work when port 80/443 are free? just needed help with the internal SSL cert setup routine by setting http_port and htps_port for local SSL certs on ports other than 80/443 for my usage on domains on port 81/4444.

So for my virtualbox install, for invalid domains used for local testing, I edited my server’s /etc/hosts and my Windows 10 pc’s C:\Windows\System32\drivers\etc\hosts

192.168.0.18 ngx.domain.com
192.168.0.18 caddy.domain.com
curl -I http://caddy.domain.com:81/caddy-index.html
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 12226
Content-Type: text/html; charset=utf-8
Etag: "q9xapl9fm"
Last-Modified: Wed, 06 May 2020 18:44:09 GMT
Server: Caddy
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Powered-By: caddy centminmod
X-Xss-Protection: 1; mode=block
Date: Fri, 08 May 2020 17:25:52 GMT
curl -Ik https://caddy.domain.com:4444/caddy-index.html
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Length: 12226
Content-Type: text/html; charset=utf-8
Etag: "q9xapl9fm"
Last-Modified: Wed, 06 May 2020 18:44:09 GMT
Server: Caddy
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Powered-By: caddy centminmod
X-Xss-Protection: 1; mode=block
Date: Fri, 08 May 2020 17:26:08 GMT
3 Likes