docker-compose.yml
version: '3.7'services:nginx:restart: alwaysimage: nginx:latestcontainer_name: nginxports:- 8080:8080volumes:- ./conf/nginx.conf:/etc/nginx/nginx.conf- ./wwwroot:/usr/share/nginx/wwwroot
配置
在/usr/loacl/docker/nginx/conf/下创建nginx.conf文件
# 核心数量worker_processes 1;events {# 连接数worker_connections 1024;}# http代理http {include mime.types;default_type application/octet-stream;sendfile on;keepalive_timeout 65;server {listen 8080;server_name www.hzlim.cn;location / {add_header Access-Control-Allow-Origin *;add_header Access-Control-Allow-Headers X-Requested-With;add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,PATCH,OPTIONS;root /usr/share/nginx/wwwroot;index index.html index.htm;}}}
