@
evanshh 你这个直接创建一个 nginx.conf 映射进去容器里面就可以啦,例如我创建 nginx.conf
```bash
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for '
'upstream_addr:"$upstream_addr" upstream_status:"$upstream_status" upstream_response_time:"$upstream_response_time" request_time:"$request_time"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
# 开启 gzip
gzip on;
# 启用 gzip 压缩的最小文件,小于设置值的文件将不会压缩
gzip_min_length 1k;
# gzip 压缩级别,1-10,数字越大压缩的越好,也越占用 CPU 时间
gzip_comp_level 6;
# 进行压缩的文件类型。javascript 有多种形式。其中的值可以在 mime.types 文件中找到。
# text/plain text/css application/javascript application/json application/x-javascript application/xml text/javascript 此部分和生成的有重复
gzip_types application/x-httpd-php image/jpeg image/gif image/png font/ttf font/otf image/svg+xml;
# 是否在 http header 中添加 Vary: Accept-Encoding,建议开启
gzip_vary on;
# 禁用 IE 6 gzip
gzip_disable "MSIE [1-6]\.";
# 最大上传大小
client_max_body_size 250M;
include /etc/nginx/conf.d/*.conf;
}
daemon off;
```
然后在容器启动时映射- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro ;就可以覆盖主配置了