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
......@@ -6,29 +6,14 @@ REGISTRY_URL=registry:5000
66 PICO_SECRET=""
77 PICO_SECRET_WEBHOOK=""
88
9-MINIO_CADDYFILE=./caddy/Caddyfile.minio
10-MINIO_DOMAIN=minio.dev.pico.sh
11-MINIO_EMAIL=hello@pico.sh
12-MINIO_URL=http://minio:9000
13-MINIO_BROWSER_REDIRECT_URL=http://console.$MINIO_DOMAIN:9001
14-MINIO_ROOT_USER=miniosecret
15-MINIO_ROOT_PASSWORD=miniosecret
16-MINIO_PROMETHEUS_AUTH_TYPE=public
17-MINIO_PROMETHEUS_URL=
18-MINIO_PROMETHEUS_JOB_ID=minio
19-
209 IMGPROXY_DOMAIN=imgproxy.dev.pico.sh
2110 IMGPROXY_URL=http://imgproxy:8080
22-IMGPROXY_ALLOWED_SOURCES=s3://,local://
11+IMGPROXY_ALLOWED_SOURCES=local://
2312 IMGPROXY_LOCAL_FILESYSTEM_ROOT=/storage
24-IMGPROXY_USE_S3=true
2513 IMGPROXY_USE_LAST_MODIFIED=true
2614 IMGPROXY_USE_ETAG=true
27-IMGPROXY_S3_ENDPOINT=http://minio:9000
2815 IMGPROXY_KEY=6465616462656566 # deadbeef
2916 IMGPROXY_SALT=6465616462656566 # deadbeef
30-AWS_ACCESS_KEY_ID=$MINIO_ROOT_USER
31-AWS_SECRET_ACCESS_KEY=$MINIO_ROOT_PASSWORD
3217 IMGPROXY_PROMETHEUS_BIND=:8081
3318 IMGPROXY_PROMETHEUS_NAMESPACE=imgproxy
3419
+1, -1
......@@ -153,7 +153,7 @@ func (h *ApiAssetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
153153 attempts = append(attempts, fpath)
154154 logger = logger.With("object", fpath)
155155
156- imgproxy := storage.NewImgProxy(fpath, h.ImgProcessOpts)
156+ imgproxy := storage.NewImgProxy(fmt.Sprintf("%s/%s", h.Bucket.Name, fpath), h.ImgProcessOpts)
157157 err = imgproxy.CanServe()
158158 if err == nil {
159159 logger.Info("serving image with imgproxy")
+10, -3
......@@ -25,13 +25,14 @@ type ImgProxy struct {
2525 }
2626
2727 func NewImgProxy(fp string, opts *ImgProcessOpts) *ImgProxy {
28- return &ImgProxy{
28+ img := &ImgProxy{
2929 url: os.Getenv("IMGPROXY_URL"),
3030 salt: os.Getenv("IMGPROXY_SALT"),
3131 key: os.Getenv("IMGPROXY_KEY"),
3232 filepath: fp,
3333 opts: opts,
3434 }
35+ return img
3536 }
3637
3738 func (img *ImgProxy) CanServe() error {
......@@ -90,7 +91,13 @@ func (img *ImgProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
9091 http.Error(w, msg, http.StatusInternalServerError)
9192 return
9293 }
93- proxy := httputil.NewSingleHostReverseProxy(destUrl)
94+ proxy := &httputil.ReverseProxy{
95+ Rewrite: func(r *httputil.ProxyRequest) {
96+ r.SetURL(destUrl)
97+ r.Out.URL.Path = destUrl.Path
98+ r.Out.URL.RawPath = destUrl.RawPath
99+ },
100+ }
94101 proxy.ServeHTTP(w, r)
95102 }
96103
......@@ -189,7 +196,7 @@ func (img *ImgProcessOpts) String() string {
189196 // Only 0, 90, 180, 270, etc., degree angles are supported.
190197 if img.Rotate != 0 {
191198 rot := img.Rotate
192- if rot == 90 || rot == 180 || rot == 280 {
199+ if rot == 90 || rot == 180 || rot == 270 {
193200 processOpts = fmt.Sprintf(
194201 "%s/rotate:%d",
195202 processOpts,