-
-
Notifications
You must be signed in to change notification settings - Fork 182
Open
Labels
bugSomething isn't workingSomething isn't workingquestionFurther information is requestedFurther information is requested
Description
我在宝塔中创建的容器,但是没有按预期转换图像后放置在缓存目录,导致网站中访问返回404,
services:
webp:
image: docker.1ms.run/webpsh/webp-server-go:0.13.3
restart: always
volumes:
- /www/wwwroot/网站目录/wp-content/uploads/:/opt/pics
- /www/wwwroot/imgwebp:/opt/exhaust
- /www/wwwroot/imgwebp_metadata:/opt/metadata
ports:
- 127.0.0.1:3333:3333
错误日志为:
问题可能的原因:
nginx存在冗余路径前缀,需要去掉 URL 中的 /wp-content/uploads 前缀,只转发后面的路径
原本是(在旧版本是这样的,可以正常运行,版本:v0.12.3):
location ~* \.(jpg|jpeg|png|gif)$ {
expires 30d;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:3333/$request_uri;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-Port $remote_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_connect_timeout 60s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
现在是(适用于版本:v0.13.3):
location ~* ^/wp-content/uploads/(.*\.(jpg|jpeg|png|gif))$ {
expires 30d;
rewrite ^/wp-content/uploads/(.*)$ /$1 break;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:3333;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-Port $remote_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_connect_timeout 60s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingquestionFurther information is requestedFurther information is requested