Test your static web apps behind an nginx reverse proxy before production.
- Nginx runs as reverse proxy on port
7878 - Your app runs behind nginx at
/apps/my-app - All logs stored locally in
volumes/folder - Easy to swap different Docker images for testing
├── docker-compose.yml # Your actual app config
├── demo-docker-compose.yml # Demo config for testing setup
├── nginx.conf # Proxy configuration
├── .env.nginx # Nginx settings
├── .env.app # Your app settings (API URLs, etc)
└── volumes/ # Logs and cache
# Start demo
docker-compose -f demo-docker-compose.yml up -d
# Check it works
open http://localhost:7878/apps/my-app
# Stop demo
docker-compose -f demo-docker-compose.yml down# Edit docker-compose.yml - change the image to yours:
# image: your-registry/your-app:tag
# Update .env.app with your API URLs and settings
# Start
docker-compose up -d
# Check logs
docker-compose logs -f
# Access
open http://localhost:7878/apps/my-appEdit docker-compose.yml:
webapp:
image: your-image:tag # Change thisEdit .env.app:
API_BASE_URL=https://your-api.com/api
NUXT_APP_BASE_URL=/apps/my-app # Must match nginx path!
# Add any other vars your app needsDefault is /apps/my-app. To change it:
- Edit
nginx.conf- changelocation /apps/my-appto your path - Edit
.env.app- updateNUXT_APP_BASE_URLto match - Restart:
docker-compose restart
In nginx.conf, there's a commented line:
#rewrite ^/apps/my-app/?(.*)$ /$1 break;- Keep commented if your app knows about the
/apps/my-appprefix - Uncomment if your app expects to serve from root
/
# Start
docker-compose up -d
# Stop
docker-compose down
# View logs
docker-compose logs -f
docker-compose logs -f webapp
docker-compose logs -f nginx
# Restart after changes
docker-compose restart
# Test with different image
docker-compose up -d --force-recreate webapp
# Clean restart
docker-compose down
rm -rf volumes/nginx/cache/* volumes/nginx/logs/*
docker-compose up -d- Your app: http://localhost:7878/apps/my-app
- Health check: http://localhost:7878/health
- Check if webapp container is running:
docker-compose ps - Check webapp logs:
docker-compose logs webapp - Restart:
docker-compose restart webapp
- Make sure you use
/apps/my-appin URL (not just/) - Check if webapp is serving content:
docker exec -it webapp sh
- Check
NUXT_APP_BASE_URLin.env.appmatches nginx path - Or enable the rewrite rule in
nginx.conf
Check container has the vars:
docker exec webapp envJust change the image and restart:
# Edit docker-compose.yml image line
nano docker-compose.yml
# Restart
docker-compose up -d --force-recreate webappLogs are stored locally:
tail -f volumes/nginx/logs/access.log
tail -f volumes/nginx/logs/error.logThat's it! Start with demo mode, then swap in your image.
docker-compose psdocker-compose exec nginx nginx -tdocker-compose exec nginx nginx -s reloaddocker network inspect local-rp_app-network