Stand-alone mode

    This method is more suitable for two types of users:

    1. kubernetes(k8s):Declarative API that dynamically updates the routing rules with a full yaml configuration.
    2. Different configuration centers: There are many implementations of the configuration center, such as Consul, etc., using the full yaml file for intermediate conversion.

    The routing rules in the file are loaded into memory immediately after the APISIX node service starts. And every time interval (default 1 second), will try to detect whether the file content is updated, if there is an update, reload the rule.

    Note: When reloading and updating routing rules, they are all hot memory updates, and there will be no replacement of working processes, it is a hot update.

    To enable Stand-alone mode, we can set apisix.config_center to yaml and disable Admin API in file conf/config.yaml.

    Refer to the example below:

    All of the rules are stored in one file which named conf/apisix.yaml, the APISIX will check if this file has any changed every second. If the file changed and we found #END at the end of the file, APISIX will load the rules in this file and update to memory of APISIX.

    1. routes:
    2. -
    3. uri: /hello
    4. upstream:
    5. nodes:
    6. "127.0.0.1:1980": 1
    7. type: roundrobin
    8. #END

    NOTE: APISIX will not load the rules into memory from file conf/apisix.yaml if there is no #END at the end.

    How to configure Router

    Single Router:

    1. routes:
    2. -
    3. uri: /hello
    4. upstream:
    5. nodes:
    6. "127.0.0.1:1980": 1
    7. type: roundrobin
    8. #END

    Multiple Router:

    1. routes:
    2. -
    3. uri: /hello
    4. upstream:
    5. nodes:
    6. type: roundrobin
    7. -
    8. uri: /hello2
    9. nodes:
    10. "127.0.0.1:1981": 1
    11. type: roundrobin
    12. #END

    How to configure Router + Service

    1. routes:
    2. -
    3. uri: /hello
    4. upstream_id: 1
    5. upstreams:
    6. -
    7. id: 1
    8. nodes:
    9. "127.0.0.1:1980": 1
    10. type: roundrobin
    11. #END

    How to configure Router + Service + Upstream

    1. routes:
    2. -
    3. uri: /hello
    4. service_id: 1
    5. services:
    6. -
    7. id: 1
    8. upstream_id: 2
    9. upstreams:
    10. -
    11. id: 2
    12. nodes:
    13. "127.0.0.1:1980": 1
    14. type: roundrobin
    15. #END

    How to configure Plugins

    1. plugins:
    2. - name: jwt-auth
    3. - name: mqtt-proxy
    4. stream: true # set 'stream' to true for stream plugins
    5. #END

    How to configure global rule

    1. global_rules:
    2. -
    3. id: 1
    4. plugins:
    5. response-rewrite:
    6. body: "hello\n"

    How to configure consumer

    1. consumers:
    2. - username: jwt
    3. plugins:
    4. jwt-auth:
    5. key: user-key
    6. secret: my-secret-key
    1. upstreams:
    2. - id: 1
    3. nodes:
    4. "127.0.0.1:1980": 1
    5. type: roundrobin
    6. routes:
    7. -
    8. uri: /hello
    9. upstream_id: 1
    10. plugins:
    11. http-logger:
    12. batch_max_size: 1
    13. uri: http://127.0.0.1:1980/log
    14. plugin_metadata:
    15. - id: http-logger # note the id is the plugin name
    16. log_format:
    17. remote_addr: "$remote_addr"

    How to configure stream route