-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnginx.conf
40 lines (31 loc) · 1.37 KB
/
nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
user root; # nginx 用户权限 执行lua创建图片命令需要读写权限
worker_processes auto;
error_log /var/log/nginx/error.log;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
map $http_accept $webp_suffix { # 检测accept中是否支持webp图片格式
default "";
"~*webp" ".webp";
}
server {
listen 80;
listen [::]:80 default_server;
server_name webp.leewr.com;
root /home/leewr/mono/app/public/december; # 你站点的位置
location ~* ^(.+\.(jpg|png|jpeg|gif))(.webp)$ { # 正则匹配图片 paht/name.jpg.webp 格式的图片请求
if (!-f $request_filename) { # 如果图片不存在
access_log /usr/local/nginx/logs/ImageResizer.log main; # 设置日志文件
set $request_filepath /home/leewr/mono/app/public/december$1; # 设置图片真实路径的变量
set $ext $3; # 设置图片扩展名$ext变量
content_by_lua_file lua/webp.lua; # 调用nginx/lua目录下的webp.lua文件
}
}
}
}