Combining Global and Route-Specific Plugins in ApisixRoute #12024
Replies: 1 comment
-
Hey @sopacifics! I'm here to help you with any bugs, questions, or contributions. Let's tackle this issue together while we wait for a human maintainer. Yes, there is a supported way to achieve this in APISIX. You can use the ApisixPluginConfig CRD to extract and reuse commonly used plugins and bind them directly to a route. This allows you to avoid duplicating the global configuration on each route. When you use Here's an example of how you can configure this: apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
name: nginx-route
namespace: api-gateway
spec:
http:
- name: nginx-rule
match:
paths:
- /nginx/*
plugin_config_name: nginx-oidc-global
plugins:
- name: proxy-rewrite
enable: true
config:
regex_uri:
- "^/nginx/(.*)"
- "/$1"
backends:
- serviceName: nginx-service
servicePort: 80 In this setup, the To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other |
Beta Was this translation helpful? Give feedback.
-
Hi APISIX Team,
We are currently facing an issue when trying to combine the use of
plugin_config_name
with inlineplugins
definitions within a single ApisixRoute resource. Our goal is to have a global plugin (for example, an OIDC configuration) applied to multiple routes, while still allowing route-specific plugins (such as proxy-rewrite) to be defined inline without repeating the global configuration on every route.Scenario:
Not Working (Using Both
plugin_config_name
and inlineplugins
):In this configuration, only the plugins defined in the referenced ApisixPluginConfig (
nginx-oidc-global
) are applied. The inlineproxy-rewrite
plugin is ignored.Working (Defining All Plugins Inline):
In this case, both the OIDC and proxy-rewrite plugins are applied, but I need to repeat the OIDC configuration in every ApisixRoute.
Question:
Is there any supported way to combine a global plugin configuration (such as openid-connect via
plugin_config_name
) with additional route-specific plugins (like proxy-rewrite) in a single ApisixRoute resource without having to duplicate the global configuration on each route? If not, is the recommended approach to handle this scenario?We’d appreciate any guidance or workarounds you might suggest for this scenario.
Thanks in advance for your help!
Best regards,
Sofia
Beta Was this translation helpful? Give feedback.
All reactions