This folder contains all the scripts and configuration files needed to run the Marine Licensing Frontend application locally with HTTPS support and on how to point local to cp dev defra id instance instead of stub.
-
Install mkcert (for local SSL certificates):
brew install mkcert mkcert -install
Or with macports
sudo port install mkcert
-
Install nginx (if not already installed):
brew install nginx
Or with macports:
sudo port install nginx # Do not configure to run at startup -
Set up nginx directories (required for Homebrew nginx):
sudo mkdir -p /usr/local/var/run/nginx sudo chown -R $(whoami):admin /usr/local/var/run/nginx⚠️ Important: This step is required to set the working directory correctly for Homebrew installed nginx.For Macports: the default config file is
/opt/local/etc/nginx/nginx.conf -
Generate SSL certificates (first time only):
cd local-https-setup mkcert marine-licensing-frontend.test.cdp-int.defra.cloud cd ..
⚠️ Important: SSL certificates are generated locally and should NOT be committed to the repository. The certificates are already in.gitignoreto prevent accidental commits. -
Enable local DNS (first time only):
./local-https-setup/toggle-local-dns.sh
-
Rename the .env.template file in the frontend repo root, to .env (it will be git-ignored) and obtain the missing secret values from another team member. Compare other values with here https://github.com/DEFRA/cdp-app-config/blob/main/services/marine-licensing-frontend/test/marine-licensing-frontend.env
-
Rename the .env.template in the backend repo root as .env and check the values are the same as https://github.com/DEFRA/cdp-app-config/blob/main/services/marine-licensing-backend/test/marine-licensing-backend.env
./local-https-setup/start-with-https.shnginx-https.conf- Nginx configuration for HTTP and HTTPS reverse proxyREADME.md- This documentation file
start-with-https.sh- Starts application with HTTPS supporttoggle-local-dns.sh- Toggle between local and remote DNS resolutionstop-all.sh- Stop all running processes and clean up
Browser → HTTPS (443) → Nginx → HTTP (3000) → Node.js App
Browser → HTTP (80) → Nginx → HTTP (3000) → Node.js App
- Nginx Reverse Proxy: Handles SSL termination and forwards requests to localhost:3000
- SSL Certificates: Generated by mkcert for local development
- DNS Resolution: Local /etc/hosts entry for domain mapping
- Environment Variables: Configured for OIDC and base URL
Once started, access your application at:
- HTTP:
http://marine-licensing-frontend.test.cdp-int.defra.cloud - HTTPS:
https://marine-licensing-frontend.test.cdp-int.defra.cloud
./local-https-setup/toggle-local-dns.shThis will:
- Add
127.0.0.1 marine-licensing-frontend.test.cdp-int.defra.cloudto /etc/hosts - Flush DNS cache
- Domain will resolve to localhost
./local-https-setup/toggle-local-dns.shThis will:
- Comment out the local DNS entry
- Flush DNS cache
- Domain will resolve to remote test environment
Press Ctrl+C in the terminal where the startup script is running.
./local-https-setup/stop-all.shIf you see SSL errors:
- Ensure mkcert is installed:
brew install mkcert - Install mkcert root CA:
mkcert -install - Generate new certificates:
cd local-https-setup rm -f *.pem # Remove existing certificates mkcert marine-licensing-frontend.test.cdp-int.defra.cloud cd ..
Note: Each developer should generate their own SSL certificates locally. Never commit certificate files to the repository.
If ports are already in use:
./local-https-setup/stop-all.shIf domain doesn't resolve:
- Check /etc/hosts entry:
grep marine-licensing-frontend.test.cdp-int.defra.cloud /etc/hosts - Flush DNS cache:
sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder - Use toggle script:
./local-https-setup/toggle-local-dns.sh
The scripts automatically set these environment variables:
APP_BASE_URL:https://marine-licensing-frontend.test.cdp-int.defra.cloud
If you prefer to run commands manually:
sudo nginx -c $(pwd)/local-https-setup/nginx-https.confexport APP_BASE_URL=https://marine-licensing-frontend.test.cdp-int.defra.cloud
npm run devsudo nginx -s stop- SSL certificates are for local development only
- Never use these certificates in production
- The setup uses self-signed certificates generated by mkcert
- Browser may show security warnings - this is normal for local development
- SSL certificates are NOT committed to the repository - each developer generates their own locally
- Certificate files (
*.pem) are excluded via.gitignoreto prevent accidental commits
If you encounter issues:
- Check the troubleshooting section above
- Verify all prerequisites are installed
- Ensure no other services are using ports 80, 443, or 3000
- Check application logs for specific error messages