services:
helloworld:
container_name: helloworld
image: crccheck/hello-world
nginx:
image: nginx:latest
container_name: nginx
restart: always
ports:
- 80:80
- 443:443
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./certbot/conf:/etc/letsencrypt
- ./certbot/www:/var/www/certbot
- ./nginx/logs:/var/log/nginx
tty: true
stdin_open: true
healthcheck:
test: ["CMD", "nginx", "-t"]
interval: 30s
timeout: 10s
retries: 3
certbot:
image: certbot/certbot
container_name: certbot
volumes:
- ./certbot/conf:/etc/letsencrypt
- ./certbot/www:/var/www/certbot
- ./certbot/logs:/var/log/letsencrypt
command: certonly --webroot -w /var/www/certbot --non-interactive --email bachlang364@gmail.com -d sieunhan.langbach.io.vn --agree-tos --dry-run
networks:
default:
name: my_network
here is my docker configuration from yml file
worker_processes auto;
worker_cpu_affinity auto;
events {
multi_accept on;
worker_connections 1024;
}
http {
charset utf-8;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
log_not_found off;
types_hash_max_size 4096;
client_max_body_size 16M;
types_hash_bucket_size 128;
keepalive_timeout 65;
include mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log warn;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server_tokens off;
charset utf-8;
server {
listen 80;
listen [::]:80;
server_name sieunhan.langbach.io.vn;
access_log /var/log/nginx/access_80.log combined;
location /.well-known/acme-challenge/ {
allow all;
root /var/www/certbot;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
server_name sieunhan.langbach.io.vn;
ssl_certificate /etc/letsencrypt/live/sieunhan.langbach.io.vn/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/sieunhan.langbach.io.vn/privkey.pem;
root /var/www/html;
index index.php index.html index.htm;
location / {
proxy_pass http://helloworld:8000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /.well-known/acme-challenge/ {
allow all;
root /var/www/certbot;
}
}
}
Here is the configuration file from my nginx.conf
${DIR}
├── docker-compose.yml
│
├── nginx/
│ ├── nginx.conf