目录
2、解决nginx下加载eot|otf|ttf|woff|svg等404 错误问题
一、准备工作
1、安装docker
参考
【Docker技术内幕】(四)Linux环境下安装docker
2、设置加速镜像
vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://mirror.ccs.tencentyun.com"]
}
systemctl restart docker
systemctl enable docker
二、开始安装
1、创建目录
mkdir -p /data/nginx81/{html,logs,conf}
2、新建配置
cd /data/nginx81
vim nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
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"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
client_max_body_size 5000m;
client_header_timeout 600;
client_body_timeout 600;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
keepalive_timeout 1800;
#gzip on;
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
}
}
cd /data/nginx81/html
vim index.html
```
nginx-index
```
3、启动容器
docker run --name nginx81 -p 81:80 \
-v /data/nginx81/nginx.conf:/etc/nginx/nginx.conf \
-v /data/nginx81/conf:/etc/nginx/conf.d \
-v /data/nginx81/logs:/var/log/nginx \
-v /data/nginx81/html:/usr/share/nginx/html \
-d nginx
四、常见问题
1、排除favicon.ico不存在的日志
location = /favicon.ico {
log_not_found off;
access_log off;
}
2、解决nginx下加载eot|otf|ttf|woff|svg等404 错误问题
location ~* .(eot|otf|ttf|woff|woff2|svg)$ {
root /usr/share/nginx/html/test-report-static;
add_header Access-Control-Allow-Origin *;
}