您的位置 首页 nginx

docker-compose 部署nginx配置ssl

有2个方案,一个是把nginx.conf 挂出来,

如果需要挂载nginx.conf  需要

docker-compose 部署nginx配置ssl_docker compose nginx ssl-CSDN博客

方案一:

version: "3"
services:
  nginx:
    image: nginx:1.25.0
    restart: always
    container_name: nginx
    environment:
      - TZ=Asia/Shanghai
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx/conf.d:/etc/nginx/conf.d
      - ./nginx/logs:/var/log/nginx
      - ./site:/usr/share/nginx/html
      - ./nginx/letsencrypt:/etc/letsencrypt

 

 

测试 的 配置文件:

cat test.conf

[root@jumps conf.d]# cat test.conf 
    server {
        listen      80;
        server_name baimeidashu.com;
        charset utf-8;
        location / {
                root   /etc;
                autoindex       on;
                autoindex_exact_size    off;
                autoindex_localtime     on;
        }
      location /download {
               alias /var/log/;
               autoindex on; # 开启目录索引功能,可选,用于展示目录内容列表
         }

}

 

 

方案2: 把nginx.conf 也挂出来

准备nginx.conf

nginx.conf-白眉大叔 (baimeidashu.com)

注意 路径: - ./nginx/nginx.conf:/etc/nginx/nginx.conf

需要先运行一下 docker compose up -d , 把目录生成后,然后把 nginx.conf 准备到指定目录。不然出错。

然后:

cat docker-compose.yaml

version: "3"
services:
  nginx:
    image: nginx:1.25.0
    restart: always
    container_name: nginx
    environment:
      - TZ=Asia/Shanghai
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx/conf.d:/etc/nginx/conf.d
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
      - ./nginx/logs:/var/log/nginx
      - ./site:/usr/share/nginx/html
      - ./nginx/letsencrypt:/etc/letsencrypt

 

欢迎来撩 : 汇总all

白眉大叔

关于白眉大叔linux云计算: 白眉大叔

热门文章