我有两台服务器,需要配置nginx http_image_filter模块。
第一个服务器配置:
server {
listen 80;
server_name image.site.com;
access_log /var/log/nginx/image.site.com-access.log;
error_log /var/log/nginx/image.site.com-error.log;
location / {
proxy_pass http://192.168.1.4;
}
}192.168.1.4上的配置为:
server {
listen 80;
server_name image.site.com;
access_log /var/log/nginx/image.site.com-access.log;
error_log /var/log/nginx/image.site.com-error.log;
root /home/zulu/img/RU/;
location ~ "/img/RU/(.*[^0-9])([0-9]+)x([0-9]+).png$" {
set $image $1;
set $width $2;
set $height $3;
image_filter resize $width $height;
}
}当我转到image.site.com/img/RU/image.png时,它不工作
我做错了什么?
发布于 2018-11-29 14:24:06
这是正确的配置:
代理
server {
listen 80;
server_name image.site.com;
access_log /var/log/nginx/image.site.com.log;
error_log /var/log/nginx/image.site.com-error.log;
location / {
proxy_pass http://192.168.151.4;
}
proxy_cache images;
proxy_cache_lock on;
proxy_cache_valid 30d;
proxy_cache_use_stale error timeout invalid_header updating;
expires 30d;
}和镜像服务器
server {
listen 80;
server_name image.site.com;
access_log /var/log/nginx/image.site.com.log;
error_log /var/log/nginx/image.site.com-error.log;
root /var/www/files/update/ServiceLogo/;
image_filter_buffer 50M;
location ~ ^/(?<width>\d+)x(?<height>\d+)/(?<name>.*)$ {
image_filter resize $width $height;
alias /var/www/files/update/ServiceLogo/$name;
}
location ~ ^/c/(?<width>\d+)x(?<height>\d+)/(?<name>.*)$ {
image_filter crop $width $height;
alias /var/www/files/update/ServiceLogo/$name;
}
location ~ ^/users/(?<width>\d+)x(?<height>\d+)/(?<name>.*)$ {
image_filter resize $width $height;
alias /var/www/files/update/personDocs/$name;
}
location ~ ^/cusers/(?<width>\d+)x(?<height>\d+)/(?<name>.*)$ {
image_filter crop $width $height;
alias /var/www/files/update/personDocs/$name;
}
}https://stackoverflow.com/questions/51857328
复制相似问题