srcmesh-workshop / docker-workshop

0 stars 40 forks source link

許登彥 #30

Open dannyHsu0702 opened 6 days ago

dannyHsu0702 commented 6 days ago
services:
  nginx:
    image: nginx:latest
    container_name: nginx_user-18
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
    depends_on:
      - wordpress
    ports:
      - '8018:80'
    healthcheck:
      test: ["CMD-SHELL", "curl -f http://localhost || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 3
  wordpress:
    image: wordpress:latest
    container_name: wordpress_user18
    environment:
      WORDPRESS_DB_HOST: mysql
      WORDPRESS_DB_USER: user
      WORDPRESS_DB_PASSWORD: user
      WORDPRESS_DB_NAME: root
    healthcheck:
      test: ["CMD-SHELL", "curl -f http://localhost || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 3
    restart: unless-stopped
"compose.yml" 56L, 1335B                                              1,9           Top
# Path to access.log & error.log
access_log /var/log/nginx/access.log  main;
error_log /var/log/nginx/error.log  warn;

sendfile        on;
keepalive_timeout  65;
gzip  on;

upstream backend {
    # must match the target service name
    server wordpress:80;
}

server {
    listen       80;
    location / {
        # $http_host is the host name that users seen on the browser URL
        # and it equals to `HTTP_HOST` request header.
        proxy_set_header Host $http_host;

        # You have to change this according to your setup.
        proxy_pass http://wordpress;

        # Modify `Location` of 301 or 302 HTTP response, so
        # that the browser will follow the correct location.
        proxy_redirect ~^http://[^/]*/(.*) http://$http_host/$1;
    }
}

} "nginx.conf" 44L, 1236B 44L, 1236B 42,1 Bot