zoukankan      html  css  js  c++  java
  • Docker-compose部署nginx

    Docker-compose部署nginx

    目录结构

    .
    | -- conf.d
    |    | -- nginx.conf
    | -- dist
    |    | -- index.html
    |    | -- 50x.html
    | -- compose-nginx.yaml
    | -- startup.sh
    

    compose-nginx.yaml

    version: '3'
    
    # docker network create nginx_bridge
    networks:
      nginx_bridge:
        driver: bridge
    
    services:
      nginx:
        image: nginx:stable-alpine
        #image: nginx:1.19.1-alpine
        container_name: nginx-alpine
        restart: always
        privileged: true
        environment:
          - TZ=Asia/Shanghai 
        ports:
          - 8080:80
          - 80:80
          - 443:443
        volumes:
          - /etc/localtime:/etc/localtime:ro
          #- ./conf/nginx.conf:/etc/nginx/nginx.conf:ro
          - ./conf.d:/etc/nginx/conf.d
          - ./log:/var/log/nginx
          - ./dist:/opt/dist:ro
        networks:
          - nginx_bridge
    
    

    nginx.conf

    这里只需要包含server配置,这个配置会内包含在容器内的nginx.conf(主配置中)

    
    server {
            listen       80;
            server_name  192.168.31.202;
            client_max_body_size    1000M;
            #root         /opt/dist;
    
            #client_max_body_size 20M;
    
            # Load configuration files for the default server block.
    
            location / {
                  root /opt/dist;
                  index index.html;
            }
    
    }
    
    

    startup.sh

    #! /usr/bin/bash
    # 定义一个名称变量
    network_name="nginx_bridge"
    
    filterName=`docker network ls | grep $network_name | awk '{ print $2 }'`
    
    if [ "$filterName" == "" ]; then
        # 不存在就创建
        docker network create $network_name
        echo "Created network $network_name success!!"
    fi
    
    docker-compose -f ./compose-nginx.yaml up -d
    docker ps -a
    docker logs -f nginx-alpine
    
    
  • 相关阅读:
    HTTP的OPTIONS请求方法
    K8s -- DaemonSet
    Nginx 变量漫谈(二)
    Nginx 变量漫谈(一)
    通俗地讲,Netty 能做什么?
    CSP AFO后可以公开的情报
    AT1219 歴史の研究
    LuoguP4165 [SCOI2007]组队
    CF708C Centroids(树形DP)
    CF208E Blood Cousins(DSU,倍增)
  • 原文地址:https://www.cnblogs.com/jockming/p/13300962.html
Copyright © 2011-2022 走看看