直接使用nginx转发本地目录
server {
listen 5676;
server_name localhost12;
location / {
root /home/web/nginx/data/;//直接将此目录转发
autoindex on;
}
}
使用dockercompose启动nginx 的情况需要额外配置以下加粗项:
1.端口要映射出去
2.目录要有nginx 的内外映射
nginx:
container_name: web-nginx
image: nginx
build:
context: ./nginx
ports:
- “5676:5676”
volumes:
- /home/web/nginx/data:/home/web/nginx/data
- ./nginx/conf/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/logs:/var/log/nginx
- ./nginx/conf.d:/etc/nginx/conf.d