Help for caddyv2 #1290

Open
opened 2026-10-05 00:38:55 +02:00 by adam · 1 comment
Owner

Hello, I need help to use caddy in reverse proxy, on the application I have no image displayed

my config

`{
http_port 80
https_port 443
#auto_https on
#auto_https disable_redirects
admin off
}

(global-encode) {
encode zstd gzip
}

(global-headers) {
header {
Cache-Control no-cache
X-Frame-Options "SAMEORIGIN"
X-Content-Type-Options nosniff
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
X-Xss-Protection "1; mode=block"
Content-Security-Policy "upgrade-insecure-requests"
Referrer-Policy "strict-origin-when-cross-origin"
Cache-Control "public, max-age=15, must-revalidate"
Feature-Policy "accelerometer 'none'; ambient-light-sensor 'none'; autoplay 'self'; camera 'none'; encrypted-media 'none'; fullscreen 'self'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; midi 'none'; payment 'none'; picture-in-picture *; speaker 'none'; sync-xhr 'none'; usb 'none'; vr 'none'"
Server "No."
}
}

(cloudflare) {
tls {
issuer acme {
email ****
dns cloudflare ****
resolvers 1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4
}
}
}

albums.****.com {
import global-encode
import cloudflare
import global-headers
reverse_proxy 192.168.1.50:83
}
`

Hello, I need help to use caddy in reverse proxy, on the application I have no image displayed my config `{ http_port 80 https_port 443 #auto_https on #auto_https disable_redirects admin off } (global-encode) { encode zstd gzip } (global-headers) { header { Cache-Control no-cache X-Frame-Options "SAMEORIGIN" X-Content-Type-Options nosniff Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" X-Xss-Protection "1; mode=block" Content-Security-Policy "upgrade-insecure-requests" Referrer-Policy "strict-origin-when-cross-origin" Cache-Control "public, max-age=15, must-revalidate" Feature-Policy "accelerometer 'none'; ambient-light-sensor 'none'; autoplay 'self'; camera 'none'; encrypted-media 'none'; fullscreen 'self'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; midi 'none'; payment 'none'; picture-in-picture *; speaker 'none'; sync-xhr 'none'; usb 'none'; vr 'none'" Server "No." } } (cloudflare) { tls { issuer acme { email **** dns cloudflare **** resolvers 1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4 } } } albums.****.com { import global-encode import cloudflare import global-headers reverse_proxy 192.168.1.50:83 } ` <!-- github-sync-id:995164085 -->
Author
Owner

I use this as a caddy config:

https://photos.example.com {
    route /* {
        @static {
            path *.ico *.css *.js *.gif *.png *.svg *.woff
        }
        @images {
            path *.jpg *.jpeg
        }

        header -Server
        header -x-powered-by
        header Feature-Policy "autoplay 'none';camera 'none';geolocation 'none';microphone 'none';payment 'none'"
        header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' code.jquery.com; style-src 'self' 'unsafe-inline' fonts.googleapis.com code.jquery.com; font-src 'self' fonts.gstatic.com; img-src 'self' data: *.tile.openstreetmap.org code.jquery.com"
        header Referrer-Policy "no-referrer"
        header X-Content-Type-Options "nosniff"
        header X-Download-Options "noopen"
        header X-Frame-Options "SAMEORIGIN"
        header X-Permitted-Cross-Domain-Policies "none"
        header X-Robots-Tag "none"
        header X-XSS-Protection "1; mode=block"
        header Strict-Transport-Security "max-age=15768000; includeSubDomains;"
        # cache images for 6 months
        header @images Cache-Control "max-age=155520000, public"
        # cache static stuff for 2 weeks
        header @static Cache-Control "max-age=1209600, public"

        reverse_proxy piwigo:8080 {
            # Prevent Piwigo from creating fucked up URLs when behind a reverse proxy
            # and when piwigo is not on a default port.
            header_up X-Forwarded-For {http.request.hostport}
        }
    }
}

Along with these "hacks" in config.inc.php

// Support X-Forwarded-Proto header for HTTPS detection
if ( $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) {
    $_SERVER['HTTPS'] = 'on';
}
// Support for X-Forwarded-For header
if ($_SERVER['HTTP_X_FORWARDED_FOR']) {
    $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
}

Note that both Caddy and Piwigo and all related things run containerized in docker.
See here for a bit more details: https://piwigo.org/forum/viewtopic.php?pid=179498#p179498

I use this as a caddy config: ``` https://photos.example.com { route /* { @static { path *.ico *.css *.js *.gif *.png *.svg *.woff } @images { path *.jpg *.jpeg } header -Server header -x-powered-by header Feature-Policy "autoplay 'none';camera 'none';geolocation 'none';microphone 'none';payment 'none'" header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' code.jquery.com; style-src 'self' 'unsafe-inline' fonts.googleapis.com code.jquery.com; font-src 'self' fonts.gstatic.com; img-src 'self' data: *.tile.openstreetmap.org code.jquery.com" header Referrer-Policy "no-referrer" header X-Content-Type-Options "nosniff" header X-Download-Options "noopen" header X-Frame-Options "SAMEORIGIN" header X-Permitted-Cross-Domain-Policies "none" header X-Robots-Tag "none" header X-XSS-Protection "1; mode=block" header Strict-Transport-Security "max-age=15768000; includeSubDomains;" # cache images for 6 months header @images Cache-Control "max-age=155520000, public" # cache static stuff for 2 weeks header @static Cache-Control "max-age=1209600, public" reverse_proxy piwigo:8080 { # Prevent Piwigo from creating fucked up URLs when behind a reverse proxy # and when piwigo is not on a default port. header_up X-Forwarded-For {http.request.hostport} } } } ``` Along with these "hacks" in `config.inc.php` ```php // Support X-Forwarded-Proto header for HTTPS detection if ( $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) { $_SERVER['HTTPS'] = 'on'; } // Support for X-Forwarded-For header if ($_SERVER['HTTP_X_FORWARDED_FOR']) { $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR']; } ``` Note that both Caddy and Piwigo and all related things run containerized in docker. See here for a bit more details: https://piwigo.org/forum/viewtopic.php?pid=179498#p179498 <!-- github-comment-id:1213383982 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#1290