美文网首页
docker-compose nginx

docker-compose nginx

作者: 夜空最亮的9星 | 来源:发表于2022-11-29 21:09 被阅读0次

预览

[root@nod-1 docker_nginx]# tree
.
|-- docker-compose.yml
`-- www
    |-- html
    |   `-- index.html
    |-- logs
    |   |-- access.log
    |   `-- error.log
    `-- nginx.conf

docker-compose.yml

version: '3'
services:
  nginx: 
    image: nginx:latest 
    container_name: nginx01
    ports:
      - 80:80     
    volumes:
      - ./www/html:/usr/share/nginx/html
      - ./www/nginx.conf:/etc/nginx/nginx.conf
      - ./www/logs:/var/log/nginx
    privileged: true  # 这个必须要,解决nginx的文件调用的权限问题

nginx.conf


#user root;
worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;

        location / {
            root   /usr/share/nginx/html;
            try_files $uri $uri/ /index.html last;
            index  index.html index.htm;
        }
        
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

相关文章

网友评论

      本文标题:docker-compose nginx

      本文链接:https://www.haomeiwen.com/subject/qajrfdtx.html