{"id":15567032,"url":"https://github.com/dirtycajunrice/subfilter","last_synced_at":"2025-10-02T21:31:48.159Z","repository":{"id":57575440,"uuid":"355417395","full_name":"dirtycajunrice/subfilter","owner":"dirtycajunrice","description":null,"archived":false,"fork":false,"pushed_at":"2021-04-07T15:46:46.000Z","size":64,"stargazers_count":13,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-10T22:37:27.161Z","etag":null,"topics":["traefik-plugin"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dirtycajunrice.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-07T05:00:47.000Z","updated_at":"2024-09-13T12:52:44.000Z","dependencies_parsed_at":"2022-09-26T19:01:55.828Z","dependency_job_id":null,"html_url":"https://github.com/dirtycajunrice/subfilter","commit_stats":null,"previous_names":["dirtycajunrice/traefik-subfilter-plugin"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirtycajunrice%2Fsubfilter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirtycajunrice%2Fsubfilter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirtycajunrice%2Fsubfilter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirtycajunrice%2Fsubfilter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dirtycajunrice","download_url":"https://codeload.github.com/dirtycajunrice/subfilter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235043938,"owners_count":18927011,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["traefik-plugin"],"created_at":"2024-10-02T17:09:45.404Z","updated_at":"2025-10-02T21:31:42.865Z","avatar_url":"https://github.com/dirtycajunrice.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Subfilter\n\n`subfilter` is a middleware plugin for [Traefik][traefik] which rewrites the HTTP response body by replacing a search\nregex by a replacement string. Subfilter was directly cloned from\n[plugin-rewritebody][rewritebody] and modified (keeping all git history) to address issues not resolved in the upstream\nrepository\n\n## Configuration\n\n### Static\n\n```toml\n[pilot]\n  token = \"xxxx\"\n\n[experimental.plugins.subfilter]\n  modulename = \"github.com/DirtyCajunRice/subfilter\"\n  version = \"v0.5.0\"\n```\n\n### Dynamic\n\nTo configure the `subfilter` plugin, create a middleware in your configuration as explained [here][middleware-docs]. The\nfollowing examples create and use `subfilter` to replace all foo occurrences by bar in the HTTP response body.\n\nIf you want to apply some limits on the response body, you can chain this middleware plugin with\nthe [Buffering middleware][buffering-middleware] from Traefik.\n\n```toml\n[http.routers]\n  [http.routers.my-router]\n    rule = \"Host(`localhost`)\"\n    middlewares = [\"subfilter-foo\"]\n    service = \"my-service\"\n\n[http.middlewares]\n  [http.middlewares.subfilter-foo.plugin.subfilter]\n    # Keep Last-Modified header returned by the HTTP service.\n    # By default, the Last-Modified header is removed.\n    lastModified = true\n\n    # Rewrites all \"foo\" occurences by \"bar\"\n    [[http.middlewares.subfilter-foo.plugin.subfilter.filters]]\n      regex = \"foo\"\n      replacement = \"bar\"\n\n[http.services]\n  [http.services.my-service]\n    [http.services.my-service.loadBalancer]\n      [[http.services.my-service.loadBalancer.servers]]\n        url = \"http://127.0.0.1\"\n```\n\n### Dynamic - Kubernetes\n\nextraArgs\n\n```yaml\n...\n- \"--experimental.plugins.subfilter.modulename=github.com/DirtyCajunRice/subfilter\"\n- \"--experimental.plugins.subfilter.version=v0.5.0\"\n...\n```\n\nMiddleware CRD\n\n```yaml\napiVersion: traefik.containo.us/v1alpha1\nkind: Middleware\nmetadata:\n  name: subfilter-foo\nspec:\n  plugin:\n    subfilter:\n      lastModified: true\n      filters:\n        - regex: foo\n          replacement: bar\n```\n\n### My Regex Fails!\n\n`subfilter` uses golang's [regexp][regexp] package. You can use [The Go Playground][playground] to test your regex.\n\nHere is a minimally viable example:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"regexp\"\n)\n\nfunc main() {\n\tr := regexp.MustCompile(`((href|src)=\")/`)\n\tbody := []byte(\"\u003chtml\u003e\u003chead\u003e\u003clink rel=\\\"stylesheet\\\" href=\\\"/style.css\\\"\u003e\u003c/head\u003e\u003c/html\u003e\")\n\treplace :=[]byte(\"${1}/subdomain/\")\n\tfmt.Printf(\"%s\\n\", r.ReplaceAll(body, replace))\n}\n```\n\n[traefik]: https://github.com/traefik/traefik\n\n[middleware-docs]: https://docs.traefik.io/middlewares/overview/\n\n[buffering-middleware]: https://docs.traefik.io/middlewares/buffering/\n\n[rewritebody]: https://github.com/traefik/plugin-rewritebody\n\n[regexp]: https://golang.org/pkg/regexp/\n\n[playground]: https://play.golang.org/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirtycajunrice%2Fsubfilter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdirtycajunrice%2Fsubfilter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirtycajunrice%2Fsubfilter/lists"}