Skip to content

Commit

Permalink
change: when deployment mode is traditional, use 9180 as Admin API's …
Browse files Browse the repository at this point in the history
…port

Signed-off-by: spacewander <[email protected]>
  • Loading branch information
spacewander committed Aug 28, 2022
1 parent 4f18a5e commit 40b0d1c
Show file tree
Hide file tree
Showing 220 changed files with 725 additions and 715 deletions.
23 changes: 1 addition & 22 deletions apisix/cli/ngx_tpl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ http {
}
{% end %}
{% if enable_admin and admin_server_addr then %}
{% if enable_admin then %}
server {
{%if https_admin then%}
listen {* admin_server_addr *} ssl;
Expand Down Expand Up @@ -621,27 +621,6 @@ http {
stub_status;
}
{% if enable_admin and not admin_server_addr then %}
location /apisix/admin {
set $upstream_scheme 'http';
set $upstream_host $http_host;
set $upstream_uri '';
{%if allow_admin then%}
{% for _, allow_ip in ipairs(allow_admin) do %}
allow {*allow_ip*};
{% end %}
deny all;
{%else%}
allow all;
{%end%}
content_by_lua_block {
apisix.http_admin()
}
}
{% end %}
{% if ssl.enable then %}
ssl_certificate_by_lua_block {
apisix.http_ssl_phase()
Expand Down
9 changes: 4 additions & 5 deletions apisix/cli/ops.lua
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,10 @@ Please modify "admin_key" in conf/config.yaml .
-- listen in admin use a separate port, support specific IP, compatible with the original style
local admin_server_addr
if yaml_conf.apisix.enable_admin then
if yaml_conf.apisix.admin_listen then
admin_server_addr = validate_and_get_listen_addr("admin port", "0.0.0.0",
yaml_conf.apisix.admin_listen.ip,
9180, yaml_conf.apisix.admin_listen.port)
end
local ip = yaml_conf.apisix.admin_listen.ip
local port = yaml_conf.apisix.admin_listen.port
admin_server_addr = validate_and_get_listen_addr("admin port", "0.0.0.0", ip,
9180, port)
end

local control_server_addr
Expand Down
10 changes: 10 additions & 0 deletions apisix/cli/schema.lua
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ local config_schema = {
https_admin = {
type = "boolean",
},
admin_listen = {
properties = {
listen = { type = "string" },
port = { type = "integer" },
},
default = {
listen = "0.0.0.0",
port = 9180,
}
},
stream_proxy = {
type = "object",
properties = {
Expand Down
4 changes: 2 additions & 2 deletions benchmark/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ sleep 3
#############################################
echo -e "\n\napisix: $worker_cnt worker + $upstream_cnt upstream + no plugin"

curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
curl http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/hello",
"plugins": {
Expand All @@ -112,7 +112,7 @@ sleep 1
#############################################
echo -e "\n\napisix: $worker_cnt worker + $upstream_cnt upstream + 2 plugins (limit-count + prometheus)"

curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
curl http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/hello",
"plugins": {
Expand Down
7 changes: 4 additions & 3 deletions conf/config-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ apisix:
allow_admin: # http://nginx.org/en/docs/http/ngx_http_access_module.html#allow
- 127.0.0.0/24 # If we don't set any IP list, then any IP access is allowed by default.
#- "::/64"
#admin_listen: # use a separate port
# ip: 127.0.0.1 # Specific IP, if not set, the default value is `0.0.0.0`.
# port: 9180
admin_listen: # use a separate port
ip: 0.0.0.0 # Specific IP, if not set, the default value is `0.0.0.0`.
port: 9180 # Specific port, which must be different from node_listen's port.

#https_admin: true # enable HTTPS when use a separate port for Admin API.
# Admin API will use conf/apisix_admin_api.crt and conf/apisix_admin_api.key as certificate.
admin_api_mtls: # Depends on `admin_listen` and `https_admin`.
Expand Down
18 changes: 9 additions & 9 deletions docs/en/latest/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ There are two different ways to achieve this in Apache APISIX:
1. Using the `vars` field in a [Route](terminology/route.md):

```shell
curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
curl -i http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/index.html",
"vars": [
Expand All @@ -131,7 +131,7 @@ curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335
}
}'

curl -i http://127.0.0.1:9080/apisix/admin/routes/2 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
curl -i http://127.0.0.1:9180/apisix/admin/routes/2 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/index.html",
"vars": [
Expand All @@ -158,7 +158,7 @@ Apache APISIX provides several different ways to achieve this:
1. Setting `http_to_https` to `true` in the [redirect](plugins/redirect.md) Plugin:

```shell
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
curl http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/hello",
"host": "foo.com",
Expand All @@ -173,7 +173,7 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f1
2. Advanced routing with `vars` in the redirect Plugin:

```shell
curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
curl -i http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/hello",
"host": "foo.com",
Expand All @@ -196,7 +196,7 @@ curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f03433
3. Using the `serverless` Plugin:

```shell
curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
curl -i http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/hello",
"plugins": {
Expand Down Expand Up @@ -398,7 +398,7 @@ curl -i http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f03433
You can use the `vars` field in a Route for matching regular expressions:

```shell
curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
curl -i http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/*",
"vars": [
Expand Down Expand Up @@ -434,7 +434,7 @@ For more info on using `vars` refer to [lua-resty-expr](https://github.com/api7/
Yes. The example below shows configuring the FQDN `httpbin.default.svc.cluster.local` (a Kubernetes service):

```shell
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
curl http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/ip",
"upstream": {
Expand Down Expand Up @@ -472,7 +472,7 @@ apisix:
Now, to access the Admin API:

```shell
$ curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: newkey' -X PUT -d '
$ curl -i http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY: newkey' -X PUT -d '
{
"uris":[ "/*" ],
"name":"admin-token-test",
Expand Down Expand Up @@ -535,7 +535,7 @@ You can check [this post](https://juejin.cn/post/6965778290619449351) for a more
To strip a prefix from a path in your route, like to take `/foo/get` and strip it to `/get`, you can use the [proxy-rewrite](plugins/proxy-rewrite.md) Plugin:

```shell
curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
curl -i http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/foo/*",
"plugins": {
Expand Down
Loading

0 comments on commit 40b0d1c

Please sign in to comment.