View Source SSL

Prefer to do local development using SSL to resemble production as much as possible.

Phoenix has a generator for creating a self-signed certificate for HTTPS testing: mix phx.gen.cert.

However, when using Phoenix's generator you'll still have a "non secure" warning. To get rid of that warning, you can generate a certificate using mkcert.

After you install mkcert, follow the steps below:

  • Create a cert directory under priv: mkdir priv/cert.
  • Generate a new certificate: mkcert -key-file priv/cert/selfsigned_key.pem -cert-file priv/cert/selfsigned.pem localhost.
  • Restart your local server: mix phx.server. You may also need to restart your browser.

Zoonk is a multi-tenant app. Multiple schools can visit this app using their custom domain or our subdomain (i.e. username.zoonk.io). Therefore, it's useful to test those domains locally. You can do so by following the steps below:

add-the-domains-to-your-hosts-file

Add the domains to your hosts file

Add any domains you'd like to test to your /etc/hosts file. In the example below, we're going to set up all domains configured when seeding the app data.

Open your hosts file: sudo nano /etc/hosts. Then, add the following lines:

127.0.0.1 zoonk.io
127.0.0.1 zoonk.zoonk.io
127.0.0.1 science.zoonk.io
127.0.0.1 example.zoonk.io
127.0.0.1 private.zoonk.io
127.0.0.1 example.com
127.0.0.1 zoonk.com.br
127.0.0.1 nested.zoonk.com.br

generate-a-certificate-for-each-domain

Generate a certificate for each domain

You can use mkcert to generate a certificate for each domain. In the example below, we're going to use the same domains as above:

mkcert -key-file priv/cert/selfsigned_key.pem -cert-file priv/cert/selfsigned.pem localhost zoonk.io zoonk.zoonk.io science.zoonk.io example.zoonk.io private.zoonk.io example.com zoonk.com.br nested.zoonk.com.br

start-your-local-server

Start your local server

That's it! You can now start your local server (mix phx.server) and test your domains using: