Laradock + mkcert Setup

November 17, 2021

Generate SSL certificate in laradock/certbot/letsencrypt folder:

sudo mkcert -install
sudo mkcert dev.jepara.com

Update docker-compose.yml nginx configuration:

nginx:
  build:
    context: ./nginx
    args:
      - PHP_UPSTREAM_CONTAINER=${NGINX_PHP_UPSTREAM_CONTAINER}
      - PHP_UPSTREAM_PORT=${NGINX_PHP_UPSTREAM_PORT}
      - CHANGE_SOURCE=${CHANGE_SOURCE}
      - http_proxy
      - https_proxy
      - no_proxy
  volumes:
    - ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER}${APP_CODE_CONTAINER_FLAG}
    - ${NGINX_HOST_LOG_PATH}:/var/log/nginx
    - ${NGINX_SITES_PATH}:/etc/nginx/sites-available
    - ${NGINX_SSL_PATH}:/etc/nginx/ssl
    - ./data/certbot/certs/:/var/certs
    - ./certbot/letsencrypt/:/var/www/letsencrypt

Add SSL configuration to jepara.conf in nginx/sites:

# For https
listen 443 ssl;
#listen [::]:443 ssl ipv6only=on;
ssl_certificate /var/www/letsencrypt/dev.jepara.com.pem;
ssl_certificate_key /var/www/letsencrypt/dev.jepara.com-key.pem;

Rebuild and restart nginx container:

docker-compose build nginx
docker-compose restart nginx
#Laradock #Docker #SSL #mkcert