基于Docker,使用Nginx搭建文件服务

    docker-compose.yml   使用docker-compose启动

version: '2'
services:
  mynginx:
    image: nginx:latest
    container_name: "mynginx"
    ports:
      - "80:80"
    volumes:
         - /data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf
         - /data/nginx/logs:/var/log/nginx
         - /data/nginx/html:/usr/share/nginx/html

    data/nginx/config      nginx配置文件
    data/nginx/html          传输文件所在目录
    data/nginx/logs          nginx访问日志目录

 

nginx配置文件

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http{
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;
    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    include /etc/nginx/conf.d/*.conf;

    server {
      listen       80;
      server_name  172.30.151.141;  # 改成自己的服务器IP

      location / {
         root   /usr/share/nginx/html;
         autoindex on;
      }
    }
}

 

上一篇:解决国产linux vmware设置了共享文件夹但启动后看不见的补丁(未完)


下一篇:hbase统计表的行数的三种方法