docker-compose nginx
2022-11-29 本文已影响0人
夜空最亮的9星
预览
[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;
}
}
}