Skip to content

Vulcain becomes a handler before encode #161

@7-zete-7

Description

@7-zete-7

Originally discussed in dunglas/symfony-docker#817.

When using FrankenPHP in its default configuration, vulcain is ordered before encode.

Example of changing the order in apps.http.servers.srv0.routes[0].handle[0].routes[2].handle of Caddy JSON config when adding order vulcain after reverse_proxy (as it was before php/frankenphp#832):

-vulcain
 encode
 mercure
+vulcain
Caddy JSON config without order
{
        "logging": {
                "logs": {
                        "default": {
                                "exclude": [
                                        "http.log.access.log0"
                                ]
                        },
                        "log0": {
                                "encoder": {
                                        "fields": {
                                                "request\u003euri": {
                                                        "actions": [
                                                                {
                                                                        "parameter": "authorization",
                                                                        "type": "replace",
                                                                        "value": "REDACTED"
                                                                }
                                                        ],
                                                        "filter": "query"
                                                }
                                        },
                                        "format": "filter"
                                },
                                "include": [
                                        "http.log.access.log0"
                                ]
                        }
                }
        },
        "apps": {
                "frankenphp": {
                        "workers": [
                                {
                                        "file_name": "./public/index.php",
                                        "env": {
                                                "APP_RUNTIME": "Runtime\\FrankenPhpSymfony\\Runtime"
                                        },
                                        "watch": [
                                                "./**/*.{php,yaml,yml,twig,env}"
                                        ]
                                }
                        ]
                },
                "http": {
                        "servers": {
                                "srv0": {
                                        "listen": [
                                                ":80"
                                        ],
                                        "routes": [
                                                {
                                                        "match": [
                                                                {
                                                                        "host": [
                                                                                "localhost"
                                                                        ]
                                                                }
                                                        ],
                                                        "handle": [
                                                                {
                                                                        "handler": "subroute",
                                                                        "routes": [
                                                                                {
                                                                                        "handle": [
                                                                                                {
                                                                                                        "handler": "vars",
                                                                                                        "root": "/app/public"
                                                                                                },
                                                                                                {
                                                                                                        "handler": "headers",
                                                                                                        "response": {
                                                                                                                "require": {
                                                                                                                        "headers": {
                                                                                                                                "Permissions-Policy": null
                                                                                                                        }
                                                                                                                },
                                                                                                                "set": {
                                                                                                                        "Permissions-Policy": [
                                                                                                                                "browsing-topics=()"
                                                                                                                        ]
                                                                                                                }
                                                                                                        }
                                                                                                }
                                                                                        ]
                                                                                },
                                                                                {
                                                                                        "group": "group0",
                                                                                        "handle": [
                                                                                                {
                                                                                                        "handler": "rewrite",
                                                                                                        "uri": "index.php"
                                                                                                }
                                                                                        ],
                                                                                        "match": [
                                                                                                {
                                                                                                        "not": [
                                                                                                                {
                                                                                                                        "path": [
                                                                                                                                "/.well-known/mercure*"
                                                                                                                        ]
                                                                                                                },
                                                                                                                {
                                                                                                                        "file": {
                                                                                                                                "try_files": [
                                                                                                                                        "{http.request.uri.path}"
                                                                                                                                ]
                                                                                                                        }
                                                                                                                }
                                                                                                        ]
                                                                                                }
                                                                                        ]
                                                                                },
                                                                                {
                                                                                        "handle": [
                                                                                                {
                                                                                                        "handler": "vulcain"
                                                                                                },
                                                                                                {
                                                                                                        "encodings": {
                                                                                                                "br": {},
                                                                                                                "gzip": {},
                                                                                                                "zstd": {}
                                                                                                        },
                                                                                                        "handler": "encode",
                                                                                                        "prefer": [
                                                                                                                "zstd",
                                                                                                                "br",
                                                                                                                "gzip"
                                                                                                        ]
                                                                                                },
                                                                                                {
                                                                                                        "demo": true,
                                                                                                        "handler": "mercure",
                                                                                                        "publisher_jwt": {
                                                                                                                "alg": "{env.MERCURE_PUBLISHER_JWT_ALG}",
                                                                                                                "key": "{env.MERCURE_PUBLISHER_JWT_KEY}"
                                                                                                        },
                                                                                                        "subscriber_jwt": {
                                                                                                                "alg": "{env.MERCURE_SUBSCRIBER_JWT_ALG}",
                                                                                                                "key": "{env.MERCURE_SUBSCRIBER_JWT_KEY}"
                                                                                                        },
                                                                                                        "transport_url": "bolt:///data/mercure.db"
                                                                                                }
                                                                                        ]
                                                                                },
                                                                                {
                                                                                        "handle": [
                                                                                                {
                                                                                                        "handler": "php"
                                                                                                }
                                                                                        ],
                                                                                        "match": [
                                                                                                {
                                                                                                        "path": [
                                                                                                                "index.php"
                                                                                                        ]
                                                                                                }
                                                                                        ]
                                                                                },
                                                                                {
                                                                                        "handle": [
                                                                                                {
                                                                                                        "handler": "file_server",
                                                                                                        "hide": [
                                                                                                                "*.php",
                                                                                                                "/etc/frankenphp/Caddyfile"
                                                                                                        ]
                                                                                                }
                                                                                        ]
                                                                                }
                                                                        ]
                                                                }
                                                        ],
                                                        "terminal": true
                                                }
                                        ],
                                        "trusted_proxies": {
                                                "ranges": [
                                                        "192.168.0.0/16",
                                                        "172.16.0.0/12",
                                                        "10.0.0.0/8",
                                                        "127.0.0.1/8",
                                                        "fd00::/8",
                                                        "::1"
                                                ],
                                                "source": "static"
                                        },
                                        "logs": {
                                                "logger_names": {
                                                        "localhost": [
                                                                "log0"
                                                        ]
                                                }
                                        }
                                }
                        }
                },
                "pki": {
                        "certificate_authorities": {
                                "local": {
                                        "install_trust": false
                                }
                        }
                }
        }
}
Caddy JSON config with order
{
        "logging": {
                "logs": {
                        "default": {
                                "exclude": [
                                        "http.log.access.log0"
                                ]
                        },
                        "log0": {
                                "encoder": {
                                        "fields": {
                                                "request\u003euri": {
                                                        "actions": [
                                                                {
                                                                        "parameter": "authorization",
                                                                        "type": "replace",
                                                                        "value": "REDACTED"
                                                                }
                                                        ],
                                                        "filter": "query"
                                                }
                                        },
                                        "format": "filter"
                                },
                                "include": [
                                        "http.log.access.log0"
                                ]
                        }
                }
        },
        "apps": {
                "frankenphp": {
                        "workers": [
                                {
                                        "file_name": "./public/index.php",
                                        "env": {
                                                "APP_RUNTIME": "Runtime\\FrankenPhpSymfony\\Runtime"
                                        },
                                        "watch": [
                                                "./**/*.{php,yaml,yml,twig,env}"
                                        ]
                                }
                        ]
                },
                "http": {
                        "servers": {
                                "srv0": {
                                        "listen": [
                                                ":80"
                                        ],
                                        "routes": [
                                                {
                                                        "match": [
                                                                {
                                                                        "host": [
                                                                                "localhost"
                                                                        ]
                                                                }
                                                        ],
                                                        "handle": [
                                                                {
                                                                        "handler": "subroute",
                                                                        "routes": [
                                                                                {
                                                                                        "handle": [
                                                                                                {
                                                                                                        "handler": "vars",
                                                                                                        "root": "/app/public"
                                                                                                },
                                                                                                {
                                                                                                        "handler": "headers",
                                                                                                        "response": {
                                                                                                                "require": {
                                                                                                                        "headers": {
                                                                                                                                "Permissions-Policy": null
                                                                                                                        }
                                                                                                                },
                                                                                                                "set": {
                                                                                                                        "Permissions-Policy": [
                                                                                                                                "browsing-topics=()"
                                                                                                                        ]
                                                                                                                }
                                                                                                        }
                                                                                                }
                                                                                        ]
                                                                                },
                                                                                {
                                                                                        "group": "group0",
                                                                                        "handle": [
                                                                                                {
                                                                                                        "handler": "rewrite",
                                                                                                        "uri": "index.php"
                                                                                                }
                                                                                        ],
                                                                                        "match": [
                                                                                                {
                                                                                                        "not": [
                                                                                                                {
                                                                                                                        "path": [
                                                                                                                                "/.well-known/mercure*"
                                                                                                                        ]
                                                                                                                },
                                                                                                                {
                                                                                                                        "file": {
                                                                                                                                "try_files": [
                                                                                                                                        "{http.request.uri.path}"
                                                                                                                                ]
                                                                                                                        }
                                                                                                                }
                                                                                                        ]
                                                                                                }
                                                                                        ]
                                                                                },
                                                                                {
                                                                                        "handle": [
                                                                                                {
                                                                                                        "encodings": {
                                                                                                                "br": {},
                                                                                                                "gzip": {},
                                                                                                                "zstd": {}
                                                                                                        },
                                                                                                        "handler": "encode",
                                                                                                        "prefer": [
                                                                                                                "zstd",
                                                                                                                "br",
                                                                                                                "gzip"
                                                                                                        ]
                                                                                                },
                                                                                                {
                                                                                                        "demo": true,
                                                                                                        "handler": "mercure",
                                                                                                        "publisher_jwt": {
                                                                                                                "alg": "{env.MERCURE_PUBLISHER_JWT_ALG}",
                                                                                                                "key": "{env.MERCURE_PUBLISHER_JWT_KEY}"
                                                                                                        },
                                                                                                        "subscriber_jwt": {
                                                                                                                "alg": "{env.MERCURE_SUBSCRIBER_JWT_ALG}",
                                                                                                                "key": "{env.MERCURE_SUBSCRIBER_JWT_KEY}"
                                                                                                        },
                                                                                                        "transport_url": "bolt:///data/mercure.db"
                                                                                                },
                                                                                                {
                                                                                                        "handler": "vulcain"
                                                                                                }
                                                                                        ]
                                                                                },
                                                                                {
                                                                                        "handle": [
                                                                                                {
                                                                                                        "handler": "php"
                                                                                                }
                                                                                        ],
                                                                                        "match": [
                                                                                                {
                                                                                                        "path": [
                                                                                                                "index.php"
                                                                                                        ]
                                                                                                }
                                                                                        ]
                                                                                },
                                                                                {
                                                                                        "handle": [
                                                                                                {
                                                                                                        "handler": "file_server",
                                                                                                        "hide": [
                                                                                                                "*.php",
                                                                                                                "/etc/frankenphp/Caddyfile"
                                                                                                        ]
                                                                                                }
                                                                                        ]
                                                                                }
                                                                        ]
                                                                }
                                                        ],
                                                        "terminal": true
                                                }
                                        ],
                                        "trusted_proxies": {
                                                "ranges": [
                                                        "192.168.0.0/16",
                                                        "172.16.0.0/12",
                                                        "10.0.0.0/8",
                                                        "127.0.0.1/8",
                                                        "fd00::/8",
                                                        "::1"
                                                ],
                                                "source": "static"
                                        },
                                        "logs": {
                                                "logger_names": {
                                                        "localhost": [
                                                                "log0"
                                                        ]
                                                }
                                        }
                                }
                        }
                },
                "pki": {
                        "certificate_authorities": {
                                "local": {
                                        "install_trust": false
                                }
                        }
                }
        }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions