Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.
This repository was archived by the owner on Oct 8, 2025. It is now read-only.

unable to proxy + rewrite in a single route #1462

@RangerRick

Description

@RangerRick

I would like to attach a sub-url to my unit config so that a particular URL proxies, but also rewrites the path passed to the proxy by stripping the sub-url.

For example, a request to /s3/mybucket/blah/foo would proxy to http://1.2.3.4:8333/mybucket/blah/foo, stripping the /s3 from the beginning the path.

I've attempted a bunch of different variations and I can't seem to find a way to make it work, although the documentation says "All route step actions support the rewrite option". Is this just not supported, or am I just doing something wrong?

Here's the config:

{
  "listeners": {
    "0.0.0.0:8080": {
      "pass": "routes/main"
    }
  },
  "routes": {
    "main": [
      {
        "match": {
          "uri": "/static/*"
        },
        "action": {
          "share": "/opt/myapp${uri}"
        }
      },
      {
        "match": {
          "uri": "~^/?s3/(.*)$"
        },
        "action": {
          "rewrite": "/$1",
          "proxy": "http://<ip-addr>:8333/"
        }
      },
      {
        "action": {
          "pass": "applications/myapp"
        }
      }
    ]
  },
  "applications": {
    "myapp": {
      "type": "python 3",
      "path": "/opt/myapp/",
      "module": "myapp.wsgi",
      "home": "/opt/myapp/venv",
      "processes": {
        "max": 4,
        "spare": 1,
        "idle_timeout": 120
      }
    }
  },
  "access_log": "/dev/stdout"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions