Skip to main content

Version: 3.8.0

Standalone Configurations

In standalone mode, APISIX fetches configuration from apisix.yaml instead of using etcd as the configuration center. These configurations are loaded into memory at startup and monitored for changes at a regular interval, without the requirement of manually reloading APISIX. It is important to note that APISIX will not load the configurations if there is no #END at the end of the file.

This document provides some configuration examples for APISIX deployed in standalone mode. To learn more information about the available configuration options, see Admin API reference.

Configure Routes

This example creates two routes to forward requests to /hello and /hello2 to different upstreams:

apisix.yaml
routes:
-
uri: /hello
upstream:
nodes:
"127.0.0.1:1980": 1
type: roundrobin
-
uri: /hello2
upstream:
nodes:
"127.0.0.1:1981": 1
type: roundrobin
#END

Configure Routes and Services

This example creates a service and a route within the service:

apisix.yaml
routes:
-
uri: /hello
service_id: 1
services:
-
id: 1
upstream:
nodes:
"127.0.0.1:1980": 1
type: roundrobin
#END

Configure Routes and Upstreams

This example creates an upstream and a route that points to the upstream:

apisix.yaml
routes:
-
uri: /hello
upstream_id: 1
upstreams:
-
id: 1
nodes:
"127.0.0.1:1980": 1
type: roundrobin
#END

Configure Routes, Services, and Upstreams

This example creates an upstream, a service, and a route within the service:

apisix.yaml
routes:
-
uri: /hello
service_id: 1
services:
-
id: 1
upstream_id: 2
upstreams:
-
id: 2
nodes:
"127.0.0.1:1980": 1
type: roundrobin
#END

Configure Plugins

This example enables three plugins:

apisix.yaml
plugins:
- name: ip-restriction
- name: jwt-auth
- name: mqtt-proxy
stream: true # set 'stream' to true for stream plugins
#END

Note that the list of plugins will override the list of plugins enabled in default-config.yaml.

Configure Plugin Global Rules

This example creates a plugin global rule:

apisix.yaml
global_rules:
-
id: 1
plugins:
response-rewrite:
body: "hello\n"
#END

Configure Plugin Metadata

This example creates plugin metadata:

apisix.yaml
upstreams:
- id: 1
nodes:
"127.0.0.1:1980": 1
type: roundrobin
routes:
-
uri: /hello
upstream_id: 1
plugins:
http-logger:
batch_max_size: 1
uri: http://127.0.0.1:1980/log
plugin_metadata:
- id: http-logger
log_format:
host: "$host",
remote_addr: "$remote_addr"
#END

Configure SSL

This example configures SSL:

apisix.yaml
ssls
-
cert: ${{SERVER_CERT}}
key: ${{SERVER_KEY}}
snis: ${{DOMAIN_NAME}}
#END

To learn more about setting environment variables, see Use Environment Variables in Configuration Files.

Configure Consumers

This example creates a consumer:

apisix.yaml
consumers:
- username: jwt
plugins:
jwt-auth:
key: user-key
secret: my-secret-key
#END

Configure Stream Routes

This example creates a stream route:

apisix.yaml
stream_routes:
- server_addr: 127.0.0.1
server_port: 1985
id: 1
upstream:
nodes:
"127.0.0.1:1981": 1
type: roundrobin
plugins:
mqtt-proxy:
protocol_name: "MQTT"
protocol_level: 4
#END

Configure Protos

This example creates a proto object:

apisix.yaml
protos:
- id: helloworld
desc: hello world
content: >
syntax = "proto3";
package helloworld;

service Greeter {
rpc SayHello (HelloRequest) returns (HelloReply) {}
}
message HelloRequest {
string name = 1;
}
message HelloReply {
string message = 1;
}
#END

API7.ai Logo

API Management for Modern Architectures with Edge, API Gateway, Kubernetes, and Service Mesh.

Product

API7 Cloud

SOC2 Type IRed Herring

Copyright © APISEVEN Ltd. 2019 – 2024. Apache, Apache APISIX, APISIX, and associated open source project names are trademarks of the

Apache Software Foundation