Commit 96bba54
Eric Bower
·
2026-06-13 20:39:16 -0400 EDT
parent 668e3cf
fix(pgs): broken url for imgproxy integration
3 files changed,
+12,
-20
+1,
-16
1@@ -6,29 +6,14 @@ REGISTRY_URL=registry:5000
2 PICO_SECRET=""
3 PICO_SECRET_WEBHOOK=""
4
5-MINIO_CADDYFILE=./caddy/Caddyfile.minio
6-MINIO_DOMAIN=minio.dev.pico.sh
7-MINIO_EMAIL=hello@pico.sh
8-MINIO_URL=http://minio:9000
9-MINIO_BROWSER_REDIRECT_URL=http://console.$MINIO_DOMAIN:9001
10-MINIO_ROOT_USER=miniosecret
11-MINIO_ROOT_PASSWORD=miniosecret
12-MINIO_PROMETHEUS_AUTH_TYPE=public
13-MINIO_PROMETHEUS_URL=
14-MINIO_PROMETHEUS_JOB_ID=minio
15-
16 IMGPROXY_DOMAIN=imgproxy.dev.pico.sh
17 IMGPROXY_URL=http://imgproxy:8080
18-IMGPROXY_ALLOWED_SOURCES=s3://,local://
19+IMGPROXY_ALLOWED_SOURCES=local://
20 IMGPROXY_LOCAL_FILESYSTEM_ROOT=/storage
21-IMGPROXY_USE_S3=true
22 IMGPROXY_USE_LAST_MODIFIED=true
23 IMGPROXY_USE_ETAG=true
24-IMGPROXY_S3_ENDPOINT=http://minio:9000
25 IMGPROXY_KEY=6465616462656566 # deadbeef
26 IMGPROXY_SALT=6465616462656566 # deadbeef
27-AWS_ACCESS_KEY_ID=$MINIO_ROOT_USER
28-AWS_SECRET_ACCESS_KEY=$MINIO_ROOT_PASSWORD
29 IMGPROXY_PROMETHEUS_BIND=:8081
30 IMGPROXY_PROMETHEUS_NAMESPACE=imgproxy
31
+1,
-1
1@@ -153,7 +153,7 @@ func (h *ApiAssetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
2 attempts = append(attempts, fpath)
3 logger = logger.With("object", fpath)
4
5- imgproxy := storage.NewImgProxy(fpath, h.ImgProcessOpts)
6+ imgproxy := storage.NewImgProxy(fmt.Sprintf("%s/%s", h.Bucket.Name, fpath), h.ImgProcessOpts)
7 err = imgproxy.CanServe()
8 if err == nil {
9 logger.Info("serving image with imgproxy")
+10,
-3
1@@ -25,13 +25,14 @@ type ImgProxy struct {
2 }
3
4 func NewImgProxy(fp string, opts *ImgProcessOpts) *ImgProxy {
5- return &ImgProxy{
6+ img := &ImgProxy{
7 url: os.Getenv("IMGPROXY_URL"),
8 salt: os.Getenv("IMGPROXY_SALT"),
9 key: os.Getenv("IMGPROXY_KEY"),
10 filepath: fp,
11 opts: opts,
12 }
13+ return img
14 }
15
16 func (img *ImgProxy) CanServe() error {
17@@ -90,7 +91,13 @@ func (img *ImgProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
18 http.Error(w, msg, http.StatusInternalServerError)
19 return
20 }
21- proxy := httputil.NewSingleHostReverseProxy(destUrl)
22+ proxy := &httputil.ReverseProxy{
23+ Rewrite: func(r *httputil.ProxyRequest) {
24+ r.SetURL(destUrl)
25+ r.Out.URL.Path = destUrl.Path
26+ r.Out.URL.RawPath = destUrl.RawPath
27+ },
28+ }
29 proxy.ServeHTTP(w, r)
30 }
31
32@@ -189,7 +196,7 @@ func (img *ImgProcessOpts) String() string {
33 // Only 0, 90, 180, 270, etc., degree angles are supported.
34 if img.Rotate != 0 {
35 rot := img.Rotate
36- if rot == 90 || rot == 180 || rot == 280 {
37+ if rot == 90 || rot == 180 || rot == 270 {
38 processOpts = fmt.Sprintf(
39 "%s/rotate:%d",
40 processOpts,