docker nginx

需要一个 autoindex 的 www。先建立一个 guoshuang_labs.conf

1
2
3
4
5
6
7
8
9
10
server {
listen 80;
server_name labs.guoshuang.com;
charset utf-8;
index index.html index.htm index.php;
root /usr/share/nginx/html/guoshuang_labs/;
location / {
autoindex on;
}
}

然后 copy 到 docker nginx 容器

1
docker cp guoshuang_labs.conf nginx:/etc/nginx/conf.d/guoshuang_labs.conf

重启

1
docker retart nginx

更多参考


1
2
3
4
5
6
# 查找镜像
docker search nginx
# 拉取镜像
docker pull nginx
# 查看本地镜像
docker images
1
docker cp nginx:/etc/nginx/conf.d/guoshuang_demo.conf guoshuang_demo.conf

进入容器

1
docker exec -it nginx bash

autoindex

1
2
3
4
5
6
location /somedirectory/ {
autoindex on;
autoindex_exact_size off;
autoindex_format html;
autoindex_localtime on;
}

autoindex_exact_size; – This directive specifies whether Nginx should display the exact file sizes of the output in the directory index or simply round to the nearest KB, MB, or GB. This directive has 2 options: on | off.

autoindex_format; – This directive specifies what format the Nginx index listing should be outputted to. This directive has 4 options: html | xml | json | jsonp.

autoindex_localtime; – This directive specifies whether the times for the directory listing should be outputted to local time or UTC. This directive has 2 options: on | off.