Skip to content

Commit 2b5326e

Browse files
Enhance Docker deployment documentation with proxy setups
Added sections on configuring reverse proxies with Nginx and Traefik, including example configurations and key differences. Included high availability setup with Docker Compose and manual build instructions.
1 parent f095e4f commit 2b5326e

1 file changed

Lines changed: 162 additions & 0 deletions

File tree

content/en/docs/deployment/docker-deploy/docker-pad.md

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,165 @@ The Mendix Runtime exposes health check endpoints that can be used to monitor th
235235
| `/health/ready` | Returns the readiness status — indicates if the app is ready to serve traffic |
236236

237237
These endpoints are especially useful when integrating with orchestration platforms such as Kubernetes, which rely on liveness and readiness probes to manage container lifecycle.
238+
239+
## Reverse Proxy
240+
241+
This section serves as a reference guide and starting point for configuring a reverse proxy on Docker. The configurations provided are intended for illustrative purposes only, as the appropriate settings will vary depending on your specific network environment and infrastructure setup.
242+
Please note that this example implementation is provided "as-is" and is not covered under official support. Support requests related to this specific configuration cannot be addressed.
243+
244+
### Nginx Configuration
245+
246+
Define services for the app and Nginx reverse proxy.
247+
248+
```
249+
services:
250+
app:
251+
build: .
252+
ports:
253+
- "127.0.0.1:8080:8080" # Bind only localhost
254+
environment:
255+
- SPRING_PROFILES_ACTIVE=docker
256+
nginx:
257+
image: nginx:alpine
258+
ports:
259+
- "80:80"
260+
volumes:
261+
- ./nginx.conf:/etc/nginx/nginx.conf:ro
262+
depends_on:
263+
- app
264+
```
265+
266+
Run with `docker-compose up --build`.​
267+
268+
Create `nginx.conf` for proxying requests to the app.
269+
270+
```
271+
events {}
272+
http {
273+
server {
274+
listen 80;
275+
location / {
276+
proxy_pass http://app:8080;
277+
proxy_set_header Host $host;
278+
proxy_set_header X-Real-IP $remote_addr;
279+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
280+
proxy_set_header X-Forwarded-Proto $scheme;
281+
}
282+
}
283+
}
284+
```
285+
286+
This setup exposes only port 80 publicly while proxying to your app on internal port 8080.
287+
288+
### Traefik configuration
289+
290+
To set up Traefik as a reverse proxy for your app running in a Docker container, use Docker Compose for simplicity. This configuration exposes Traefik on ports 80/8080, automatically discovers your app container via labels, and routes traffic to it.
291+
Traefik uses two networks: frontend (public) and backend (internal). Add Traefik labels to the app service.
292+
293+
```
294+
services:
295+
traefik:
296+
image: traefik:v3.0
297+
ports:
298+
- "80:80"
299+
- "8080:8080" # Traefik dashboard
300+
volumes:
301+
- /var/run/docker.sock:/var/run/docker.sock:ro
302+
command:
303+
- --api.dashboard=true
304+
- --providers.docker=true
305+
- --providers.docker.exposedbydefault=false
306+
- --entrypoints.web.address=:80
307+
networks:
308+
- frontend
309+
- backend
310+
restart: unless-stopped
311+
app:
312+
build: .
313+
networks:
314+
- backend
315+
labels:
316+
- traefik.enable=true
317+
- traefik.docker.network=backend
318+
- traefik.http.routers.app.rule=Host(`localhost`) || PathPrefix(`/api`)
319+
- traefik.http.routers.app.entrypoints=web
320+
- traefik.http.services.app.loadbalancer.server.port=8080
321+
restart: unless-stopped
322+
networks:
323+
frontend:
324+
external: false
325+
backend:
326+
external: false
327+
```
328+
Run with `docker compose up -d --build`.
329+
330+
Access your app at `http://localhost` (Traefik proxies to app:8080 internally).
331+
332+
**Key Traefik Labels Explained**
333+
334+
`traefik.enable=true`: Enables Traefik for this container.
335+
336+
`traefik.http.routers.java-app.rule=Host(yourapp.example.com)`: Routes requests matching the host to this service.
337+
338+
`traefik.http.services.java-app.loadbalancer.server.port=8080`: Forwards to your app's internal port.
339+
340+
Traefik auto-detects changes via Docker socket; no restarts needed for label updates.
341+
342+
**Key Differences from Nginx**
343+
344+
No static config files—Traefik auto-configures via labels.
345+
346+
Dashboard at `http://localhost:8080` shows routes.
347+
348+
Scale easily: duplicate `app service` with unique router rules (e.g., Host(app2.local)).​
349+
350+
351+
## High Availability (sample)
352+
353+
High availability requires redundancy, health checks, and restarts to handle failures. Scale for HA with Docker Compose (for local/dev) or Kubernetes:
354+
Again, this section serves as a reference guide and starting point for configuring high availability on Docker. The configurations provided are intended for illustrative purposes only, as the appropriate settings will vary depending on your specific network environment and infrastructure setup.
355+
Please note that this example implementation is provided "as-is" and is not covered under official support. Support requests related to this specific configuration cannot be addressed.
356+
357+
**docker-compose.yml:**
358+
359+
```
360+
services:
361+
myapp:
362+
image: myapp
363+
ports:
364+
- "8080:8080"
365+
deploy:
366+
replicas: 3 # Run 3 instances
367+
healthcheck:
368+
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/actuator/health"]
369+
interval: 30s
370+
timeout: 10s
371+
retries: 3
372+
```
373+
374+
Start with 'docker-compose up --scale myapp=3'.
375+
376+
Add a load balancer like Traefik or NGINX reverse proxy in front:
377+
```
378+
services:
379+
traefik:
380+
image: traefik:v3.0
381+
command: --providers.docker --entrypoints.web.address=:80
382+
ports: ["80:80"]
383+
myapp:
384+
# No ports exposed; Traefik load balances
385+
```
386+
This creates redundancy—kill one container, and traffic shifts automatically.
387+
388+
**Manual Build and Run**
389+
390+
```
391+
# Build image
392+
docker build -t myapp:latest .
393+
# Test single instance
394+
docker run -p 8080:8080 myapp:latest
395+
# For HA: Run 3 replicas (use docker-compose.yml for production)
396+
docker run -d -p 8081:8080 --name app1 myapp:latest
397+
docker run -d -p 8082:8080 --name app2 myapp:latest
398+
docker run -d -p 8083:8080 --name app3 myapp:latest
399+
```

0 commit comments

Comments
 (0)