Skip to content

feat: add embedded apisix dashboard ui#12276

Merged
bzp2010 merged 8 commits into
apache:masterfrom
bzp2010:bzp/feat-embeded-ui
Jun 4, 2025
Merged

feat: add embedded apisix dashboard ui#12276
bzp2010 merged 8 commits into
apache:masterfrom
bzp2010:bzp/feat-embeded-ui

Conversation

@bzp2010

@bzp2010 bzp2010 commented Jun 2, 2025

Copy link
Copy Markdown
Contributor

Description

Add a new embedded UI to APISIX as part of the apache/apisix-dashboard#2981 plan.

This is the infrastructure for enabling the embedded dashboard.
Subsequent work needs to be completed in the build process to include the built frontend files in the APISIX container build. This is expected to slightly increase the container image size.

Which issue(s) this PR fixes:

Fixes #12160

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@bzp2010 bzp2010 changed the title feat: add embeded apisix dashboard ui feat: add embedded apisix dashboard ui Jun 2, 2025
Comment thread apisix/cli/ngx_tpl.lua
location = /ui {
return 301 /ui/;
}
location ^~ /ui/ {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no IP or permission restrictions, which may cause security issues

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no security concerns about unauthorized access as you understand it.

Even if that ui endpoint is exposed on the Internet, the user still needs to be able to access the Admin API (/apisix/admin/xx) and have the proper credentials. And this part will undoubtedly be IP-restricted depending on the configuration.
Separate access to the UI makes no sense; that thing will be built in CI and will not contain any data about the user's environment. Without credentials and permissions, that UI will always just report errors and not display any data.

However, I recognize that this does carry some risk, mainly from the fact that if the endpoint is unintentionally exposed, it may cause bandwidth consumption on the server, but not face any potential data leakage or illegal operations.

For that reason, I'll be introducing the IP restrictions that are currently in place on the Admin API to the new endpoint at the same time to alleviate that concern.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved allow/deny on /apisix/admin to the server block level, which will resolve this issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added test cases for this.

Comment thread conf/config.yaml.example
# role: viewer

enable_admin_cors: true # Enable Admin API CORS response header `Access-Control-Allow-Origin`.
enable_admin_ui: true # Enable embedded APISIX Dashboard UI.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the role of APISIX is data plane, will enable_admin_ui be false automatically? Or we can set enable_admin_ui to false by default.

@bzp2010 bzp2010 Jun 3, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the data plane, the Admin API won't actually start at all.
Since the ui enforces the use of the Admin API port (to minimize problems with CORS), it is implicit that if the Admin API is not enabled, the ui will not be enabled.

So the answer to that question is that if the Admin API is not enabled (e.g. by turning it off on traditional, or by using data plane mode), the config item will have no effect. That is, whatever it is set to, the ui will not be exposed.

This is accomplished by a template in ngx_tpl, where location blocks about /ui/ are not rendered if the server block used by the Admin API does not exist.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I don't think anything needs to be done about it.

@bzp2010
bzp2010 requested a review from moonming June 3, 2025 05:57
@bzp2010

bzp2010 commented Jun 3, 2025

Copy link
Copy Markdown
Contributor Author

About the documentation

This integration process is not yet complete. We need to modify the APISIX build process to complete the front-end compilation in advance.
Therefore, the documentation may be submitted later via another PR.

@bzp2010
bzp2010 marked this pull request as ready for review June 3, 2025 07:38
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Jun 3, 2025
@SkyeYoung

Copy link
Copy Markdown
Member

We need to modify the APISIX build process to complete the front-end compilation in advance.

Perhaps you could try reusing the Dockerfile used to build the image in apisix-dashboard, and then copy out the final build artifacts.

@bzp2010

bzp2010 commented Jun 3, 2025

Copy link
Copy Markdown
Contributor Author

@SkyeYoung

Perhaps you could try reusing the Dockerfile used to build the image in apisix-dashboard, and then copy out the final build artifacts.

I would try to compile the frontend in the workflow and copy dist directly when building the container. Probably not modifying the Dockerfile significantly. For example, change to a multi-stage build.

@membphis membphis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@moonming moonming left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How should the Dashboard be integrated with APISIX? Should we embed the Dashboard's commit ID as part of the integration?

@juzhiyuan

juzhiyuan commented Jun 4, 2025

Copy link
Copy Markdown
Member

How should the Dashboard be integrated with APISIX? Should we embed the Dashboard's commit ID as part of the integration?

submodule (I prefer this way) or follow https://github.com/apache/apisix/blob/master/.requirements.

@juzhiyuan juzhiyuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bzp2010

bzp2010 commented Jun 4, 2025

Copy link
Copy Markdown
Contributor Author

@moonming @juzhiyuan

How should the Dashboard be integrated with APISIX? Should we embed the Dashboard's commit ID as part of the integration?

submodule (I prefer this way) or follow https://github.com/apache/apisix/blob/master/.requirements.

We need to adjust the APISIX build and release process to shift the functionality of the apisix-docker repository to the APISIX repository itself.
At that point we decided how to integrate in the build, which is now inconclusive.

No doubt these will be done before the next release.

First, let me merge this PR. After that, I will try to contact the ASF Infra team to configure Docker Hub credentials for the apisix repository. https://issues.apache.org/jira/browse/INFRA-26888

@bzp2010
bzp2010 merged commit 58066ab into apache:master Jun 4, 2025
laz-xyr pushed a commit to laz-xyr/apisix that referenced this pull request Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: support to expose APISIX Dashboard UI within APISIX

5 participants