Hey there! Have anyone build dynamic upstream usin...
# talk-oathkeeper
a
Hey there! Have anyone build dynamic upstream using ory Oathkeeper? I am wondering how can I change my upstream based on environment for external requests (develop and prod have different urls)
s
I think the best way for you should be to write different pairs of rules. As you mentioned about different environment. The url would also be different. So it would be a cleaner approach to have different set of rules all together
Copy code
- id: dev-rule
  version: v0.39.0
  upstream:
    url: <http://dev.com>
    strip_path: "/test"
  match:
    url: <https://dev.com/test/><.*>
    methods:
      - GET
      - PUT
      - POST
      - DELETE
      - PATCH
Copy code
- id: prod-rule
  version: v0.39.0
  upstream:
    url: <http://prod.com>
    strip_path: "/test"
  match:
    url: <https://prod.com/test/><.*>
    methods:
      - GET
      - PUT
      - POST
      - DELETE
      - PATCH
Having the same rule can cause issue at later stage as there might be some change that you need to address/test specific to dev and since you have common rule, it would be a big mess.
s
you could also generate the rules using some templating language or other script, in the simplest case using
sed
to string-replace the hostname, or something like jsonnet or even just some program to generate the config from one source