mikyll commented on issue #12340: URL: https://github.com/apache/apisix/issues/12340#issuecomment-2980529303
@didididi2001 some time ago I made a repository with different examples and use cases (you can find it here: [mikyll/apisix-examples](https://github.com/mikyll/apisix-examples)). ## Docker Compose Example ### Setup/Configuration File structure: ```lang-none . ├── compose.yaml ├── conf_control_plane │ └── config.yaml └── conf_data_plane └── config.yaml ``` File `compose.yaml`: ```yaml name: apisix-decoupled services: etcd: image: bitnami/etcd:latest restart: no environment: ALLOW_NONE_AUTHENTICATION: yes ports: - "2379:2379" healthcheck: test: "etcdctl endpoint health" interval: 5s timeout: 30s retries: 5 networks: apisix: apisix-data-plane: image: apache/apisix:latest restart: no depends_on: etcd: condition: service_healthy volumes: - ./conf_data_plane/config.yaml:/usr/local/apisix/conf/config.yaml:ro ports: - "9080:9080/tcp" - "9443:9443/tcp" networks: apisix: apisix-control-plane: image: apache/apisix:latest restart: no depends_on: etcd: condition: service_healthy volumes: - ./conf_control_plane/config.yaml:/usr/local/apisix/conf/config.yaml:ro ports: - "9180:9180/tcp" - "9091:9091/tcp" - "9092:9092/tcp" networks: apisix: httpbin: image: kennethreitz/httpbin:latest restart: no ports: - "3000:80/tcp" networks: apisix: networks: apisix: driver: bridge ``` File `conf_control_plane/config.yaml`: ```yaml deployment: role: control_plane role_control_plane: config_provider: etcd admin: admin_key_required: true admin_key: - name: admin key: 1a8fe9bd-73ab-493c-ac82-44db40eab641 role: admin - name: guest key: "" role: viewer allow_admin: - 127.0.0.0/24 - 0.0.0.0/0 admin_listen: ip: 0.0.0.0 port: 9180 etcd: host: - http://etcd:2379 prefix: "/apisix" timeout: 30 ``` File `conf_data_plane/config.yaml`: ```yaml apisix: router: http: radixtree_uri_with_parameter node_listen: 9080 deployment: role: data_plane role_data_plane: config_provider: etcd etcd: host: - http://etcd:2379 prefix: "/apisix" timeout: 30 ``` ### Usage Create some resources for testing: ```bash ADMIN_APIKEY="1a8fe9bd-73ab-493c-ac82-44db40eab641" # Upstreams # Upstream to internal service curl -s -i -X PUT "http://localhost:9180/apisix/admin/upstreams/internal_httpbin" -H "X-API-KEY: $ADMIN_APIKEY" -d ' { "nodes": { "httpbin:80": 1 }, "type": "roundrobin" }' # Routes # Simple route to internal service curl -s -i -X PUT "http://localhost:9180/apisix/admin/routes/base_internal" -H "X-API-KEY: $ADMIN_APIKEY" -d ' { "uri": "/anything", "upstream_id": "internal_httpbin" }' # Route with regex URI transformation curl -s -i -X PUT "http://localhost:9180/apisix/admin/routes/httpbin" -H "X-API-KEY: $ADMIN_APIKEY" -d ' { "uri": "/httpbin/*", "upstream_id": "internal_httpbin", "plugins": { "proxy-rewrite": { "regex_uri": [ "^/httpbin/(.*)", "/$1" ] } } }' ``` Test routes: ```bash curl localhost:9080/anything ``` ```bash curl localhost:9080/httpbin/get ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
