Apisix-dashboard: default login page return 404 when using APISIX for http/https proxy

Created on 12 Apr 2021  路  3Comments  路  Source: apache/apisix-dashboard

Issue description

Expected behavior

How to Reproduce

  1. deploy APISIX and etcd via docker-compose:
version: "2.3"

services:
  apisix:
    image: apache/apisix:2.4-alpine
    environment:
      - "TZ=Asia/Shanghai"
    ports:
      - "80:80/tcp"
      - "443:443/tcp"
      # - "9180:9180/tcp"
    privileged: true
    sysctls:
      - net.core.somaxconn=20480
    restart: always
    volumes:
      # - apisixlogdata1:/usr/local/apisix/logs
      - '/Application/docker/conf/apisix/2.4/config.yaml:/usr/local/apisix/conf/config.yaml:ro'
      # - '/Application/docker/conf/apisix/2.4/config-default.yaml:/usr/local/apisix/conf/config-default.yaml:ro'
      # - '/Application/docker/conf/apisix/etc/ssl/openssl.cnf:/usr/local/openresty/openssl/ssl/openssl.cnf:ro'
      # - '/Application/docker/conf/apisix/2.4/usr/local/apisix/apisix/cli/ngx_tpl.lua:/usr/local/apisix/apisix/cli/ngx_tpl.lua:ro'
    network_mode: host
version: "3"

services:
  etcd:
    # if you are in the mainland China, please use Azure China mirror:
    image: docker pull quay.io/coreos/etcd:v3.4.15
    command: /usr/local/bin/etcd
    restart: always
    volumes:
      - etcddata1:/etcd_data
    environment:
      # - ALLOW_NONE_AUTHENTICATION=yes
      - ETCDCTL_API=3
      - ETCD_DATA_DIR=/etcd_data
      - ETCD_ADVERTISE_CLIENT_URLS=http://0.0.0.0:2379
      - ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379
      - ETCD_LISTEN_CLIENT_PEER_URLS=http://127.0.0.1:2380
      - TZ=Asia/Shanghai
    network_mode: host
    ports:
      - "0.0.0.0:2379:2379/tcp"

volumes:
  etcddata1:
    driver: local
    driver_opts:
      type: 'none'
      o: 'bind'
      device: '/data/docker/etcd/node1'

  1. add route in APISIX
{
  "uris": [
    "/*"
  ],
  "name": "apisix_proxy_dashboard",
  "upstream": {
    "nodes": [
      {
        "host": "127.0.0.1",
        "port": 9000,
        "weight": 1
      }
    ],
    "type": "roundrobin"
  },
  "status": 1
}

OR

# route
{
  "uris": [
    "/*"
  ],
  "name": "https_pilot",
  "desc": "https://pilot.x.info",
  "priority": 10,
  "hosts": [
    "pilot.x.info"
  ],
  "upstream_id": "349271367952106974",
  "status": 1
}

# upstream
{
  "nodes": [
    {
      "host": "127.0.0.1",
      "port": 9000,
      "weight": 10
    }
  ],
  "timeout": {
    "connect": 6000,
    "read": 60000,
    "send": 60000
  },
  "type": "roundrobin",
  "pass_host": "pass",
  "name": "apisix manager api",
  "desc": "apisix manager api"
}
  1. Access this route via ip or:
    https://pilot.x.info/user/login?redirect=%2F

  2. Input user && password, press login

  3. See error

Screenshots

image

Left: Access dashboard via APISIX,
Right: Direct access dashboard via http://ip:9000

Environment

  • apisix version (cmd: apisix version): apisix:2.4-alpine
  • OS (cmd: uname -a): CentOS 7 ( dashboard 2.5 rpm)
  • OpenResty / Nginx version (cmd: nginx -V or openresty -V): apisix:2.4-alpine bundled openresty
  • etcd version, if have (cmd: run curl http://127.0.0.1:9090/v1/server_info to get the info from server-info API): 3.4.15
  • apisix-dashboard version, if have: 2.5
  • Browser version, if have: Chrome 88.0.4324.104

Additional context

bug

Most helpful comment

It works. I am wondering why should this happen...? Port conflict or?

Because Dashboard access needs to occupy the port of /apisix/admin/xxx, and on the data side, the default APISIX and Admin API listening ports are the same. When using APISIX proxy to access Dashboard, it will conflict with APISIX's Admin API listening interface. Therefore, we need to customize the Admin API port to avoid conflicts, or disable the Admin API.

All 3 comments

Access Dashboard through APISIX proxy, Keep the APISIX proxy port and Admin API port different(or disable Admin API). For example, do the following configuration in conf/config.yaml.

The Admin API use a separate port 9180:

apisix:
  port_admin: 9180            # use a separate port

Access Dashboard through APISIX proxy, Keep the APISIX proxy port and Admin API port different(or disable Admin API). For example, do the following configuration in conf/config.yaml.

The Admin API use a separate port 9180:

apisix:
  port_admin: 9180            # use a separate port

It works. I am wondering why should this happen...? Port conflict or?

+++ b /conf/apisix/2.4/config.yaml
@@ -1,6 +1,7 @@
 apisix:
   node_listen: 80              # APISIX listening port
   enable_ipv6: false
+  port_admin: 9180

It works. I am wondering why should this happen...? Port conflict or?

Because Dashboard access needs to occupy the port of /apisix/admin/xxx, and on the data side, the default APISIX and Admin API listening ports are the same. When using APISIX proxy to access Dashboard, it will conflict with APISIX's Admin API listening interface. Therefore, we need to customize the Admin API port to avoid conflicts, or disable the Admin API.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

juzhiyuan picture juzhiyuan  路  3Comments

Applenice picture Applenice  路  4Comments

chenyicai picture chenyicai  路  4Comments

membphis picture membphis  路  6Comments

moonming picture moonming  路  6Comments