Web Server
The web server container responds to HTTP(s) requests and runs cron.
The web server container has all you need enabled for development; you can specify custom configurations using the ./docker/webserver/templates/* files.
In addition, the following directories are of interest:
The web root is available at
./wwwWeb server logs are available at
./docker/webserver/logsLetsEncrypt certificates are available at
./docker/webserver/letsencrypt
On first make up the www folder will be created and the chosen framework (if applicable) installed into it.
SSL
Upon running make up the web server container will generate a certificate for the configured $DOMAIN, if one has already been generated it'll be reinstalled if it isn't already.
When working on localhost a self-signed certificate will be used, for all other domains (as specified by the $DOMAIN env var) both the naked domain and www subdomain will have a Let's Encrypt certificate generated and installed.
When working on localhost expect for your browser to throw insecure errors. This is because a self-signed certificate is being used. You can trust this certificate on your development machine to avoid this error.
Certificates will be renewed automatically by certbot using root's crontab; if you need to create or renew these manually then you are free to use the make ssl-create and make ssl-renew commands.
Trusting the localhost self-signed certificate
localhost self-signed certificateTo avoid "insecure website" errors and to show a padlock in your browser you can trust the certificate included in the Environment. This certificate is identical between all instances of the Docker environment so trusting it for one project will mean it is trusted for another.
How you do this depends on your OS:
Locate
./docker/webserver/ssl/localhost.crtOpen Keychain Access
Navigate to the
Certificatessection in the sidebarDrag the certifiate into Keychain Access
Double click the certificate
Under the
Trustsection, set it toAlways TrustClose the window, you will be asked for your password
Your Mac will now trust this certificate when it is used 🎉
Locate
./docker/webserver/ssl/localhost.crtDouble click the certificate, then click Next
Choose Place all certificates in the following store and click Browse...
Choose Trusted Root Certification Authorities and click OK
Cick Next then Finish
Finally, restart your computer ✨
🕵️♂️ If you are extra cautious you may wish to generate your own self-signed certificate. You can inspect the generation process used [and regenerate certs] in:
Note: If you do re-generate a certificate you will need to trust each project independently or copy this new certificate into your existing and future projects.
Securing additional domains
By default, certbot will check DNS for $DOMAIN and www.$DOMAIN and generate a single certificate for both. If you need to add additional domains to the certificate you can do so by specifying them as a comma separated list as the $SSL_ADDITIONAL_DOMAINS env var.
Cron
There is an empty crontab which you can populate at ./docker/webserver/crontab. This will populate in the web server when make up is called. If needed, you can populate root's crontab using the template at ./docker/webserver/crontab-root.
The crontab is synced to the container each time make up is called. Changes made within the container (using crontab -e) will be synced back to the host immediately.
Last updated
Was this helpful?