QOS Overview

The design purpose and usage instructions of the QoS command, including how to enable and disable the qos command, supporting HTTP/Telnet access methods.

How to Use

QoS provides some startup parameters for configuration, mainly including:

ParameterDescriptionDefault Value
qos-enableWhether to enable QoStrue
qos-portThe port that QoS binds to22222
qos-accept-foreign-ipWhether to allow remote accessfalse
qos-accept-foreign-ip-whitelistSupported remote host IP addresses (segments)(none)
qos-anonymous-access-permission-levelSupported permission level for anonymous accessPUBLIC(1)

Note: Starting from 2.6.4/2.7.0, the default configuration of qos-accept-foreign-ip is changed to false. If qos-accept-foreign-ip is set to true, it may pose security risks; please evaluate carefully before enabling.

telnet and HTTP Protocol

The telnet module now simultaneously supports HTTP protocol and telnet protocol for ease of use in various situations. Example:

  1. ~ telnet localhost 22222
  2. Trying ::1...
  3. telnet: connect to address ::1: Connection refused
  4. Trying 127.0.0.1...
  5. Connected to localhost.
  6. Escape character is '^]'.
  7. ████████▄ ███ █▄ ▀█████████▄ ▀█████████▄ ▄██████▄
  8. ███ ▀███ ███ ███ ███ ███ ███ ███ ███ ███
  9. ███ ███ ███ ███ ███ ███ ███ ███ ███ ███
  10. ███ ███ ███ ███ ▄███▄▄▄██▀ ▄███▄▄▄██▀ ███ ███
  11. ███ ███ ███ ███ ▀▀███▀▀▀██▄ ▀▀███▀▀▀██▄ ███ ███
  12. ███ ███ ███ ███ ███ ██▄ ███ ██▄ ███ ███
  13. ███ ▄███ ███ ███ ███ ███ ███ ███ ███ ███
  14. ████████▀ ████████▀ ▄█████████▀ ▄█████████▀ ▀██████▀
  15. dubbo>ls
  16. As Provider side:
  17. +----------------------------------+---+
  18. | Provider Service Name |PUB|
  19. +----------------------------------+---+
  20. |org.apache.dubbo.demo.DemoService| N |
  21. +----------------------------------+---+
  22. As Consumer side:
  23. +---------------------+---+
  24. |Consumer Service Name|NUM|
  25. +---------------------+---+
  26. dubbo>

Port

The new version of the telnet port is different from the dubbo protocol port, defaulting to 22222.

It can be modified in the configuration file dubbo.properties:

  1. dubbo.application.qos-port=33333

or

It can be set via JVM parameters:

  1. -Ddubbo.application.qos-port=33333

Security

By default, dubbo accepts commands initiated from any host.

It can be modified in the configuration file dubbo.properties:

  1. dubbo.application.qos-accept-foreign-ip=false

or

It can be set via JVM parameters:

  1. -Ddubbo.application.qos-accept-foreign-ip=false

to reject commands from remote hosts, allowing only local execution.

You can also specify supported remote host IP addresses (segments) using qos-accept-foreign-ip-whitelist, separating multiple IP addresses (segments) with commas, like:

In the dubbo.properties file:

  1. dubbo.application.qos-accept-foreign-ip-whitelist=123.12.10.13, 132.12.10.13/24

Set JVM parameters:

  1. -Ddubbo.application.qos-accept-foreign-ip-whitelist=123.12.10.13,132.12.10.13/24

Permission

To support the lifecycle probe by default, QoS offers anonymous access and permission level settings. The currently supported permission levels are:

  • PUBLIC(1)
    The default permission level for anonymous access commands, currently only supports lifecycle probe related commands.
  • PROTECTED(2)
    The default permission level for commands.
  • PRIVATE(3)
    The highest reserved permission level, currently unsupported.
  • NONE(4) The lowest permission level, which does not support anonymous access.

Permission levels are PRIVATE > PROTECTED > PUBLIC > NONE, higher-level permissions can access commands of equal or lower level. Currently, the following commands have a permission of PUBLIC, while other commands have a default permission of PROTECTED.

CommandPermission Level
LivePUBLIC (1)
StartupPUBLIC (1)
ReadyPUBLIC (1)
QuitPUBLIC (1)

By default, dubbo allows anonymous hosts to initiate anonymous access, and only commands with PUBLIC permission level can be executed; commands with higher permissions will be rejected.

Disable Anonymous Access
You can disable anonymous access by setting qos-anonymous-access-permission-level=NONE.

Set Permission Level
You can modify it in the dubbo.properties file:

  1. dubbo.application.qos-anonymous-access-permission-level=PROTECTED

or

Set JVM parameters:

  1. -Ddubbo.application.qos-anonymous-access-permission-level=PROTECTED

to allow anonymous access to higher-level permission commands.

  1. ~ curl "localhost:22222/ls?arg1=xxx&arg2=xxxx"
  2. As Provider side:
  3. +----------------------------------+---+
  4. | Provider Service Name |PUB|
  5. +----------------------------------+---+
  6. |org.apache.dubbo.demo.DemoService| N |
  7. +----------------------------------+---+
  8. As Consumer side:
  9. +---------------------+---+
  10. |Consumer Service Name|NUM|
  11. +---------------------+---+

Configuration Methods

Priority Order: System Properties > dubbo.properties > XML/Spring-boot Autowiring

System Properties

  1. -Ddubbo.application.qos-enable=true
  2. -Ddubbo.application.qos-port=33333
  3. -Ddubbo.application.qos-accept-foreign-ip=false
  4. -Ddubbo.application.qos-accept-foreign-ip-whitelist=123.12.10.13,132.12.10.13/24
  5. -Ddubbo.application.qos-anonymous-access-permission-level=PUBLIC

dubbo.properties

Add the dubbo.properties file in the project’s src/main/resources directory, with the following content:

  1. dubbo.application.qos-enable=true
  2. dubbo.application.qos-port=33333
  3. dubbo.application.qos-accept-foreign-ip=false
  4. dubbo.application.qos-accept-foreign-ip-whitelist=123.12.10.13, 132.12.10.13/24
  5. dubbo.application.qos-anonymous-access-permission-level=PUBLIC

XML

If you want to configure QoS related parameters through XML, you can configure as follows:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
  5. xsi:schemaLocation="http://www.springframework.org/schema/beans
  6. http://www.springframework.org/schema/beans/spring-beans.xsd
  7. http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
  8. <dubbo:application name="demo-provider">
  9. <dubbo:parameter key="qos-enable" value="true"/>
  10. <dubbo:parameter key="qos-accept-foreign-ip" value="false"/>
  11. <dubbo:parameter key="qos-accept-foreign-ip-whitelist" value="123.12.10.13,132.12.10.13/24"/>
  12. <dubbo:parameter key="qos-anonymous-access-permission-level" value="NONE"/>
  13. <dubbo:parameter key="qos-port" value="33333"/>
  14. </dubbo:application>
  15. <dubbo:registry address="multicast://224.5.6.7:1234"/>
  16. <dubbo:protocol name="dubbo" port="20880"/>
  17. <dubbo:service interface="org.apache.dubbo.demo.provider.DemoService" ref="demoService"/>
  18. <bean id="demoService" class="org.apache.dubbo.demo.provider.DemoServiceImpl"/>
  19. </beans>

Spring Boot Autowiring

For Spring Boot applications, you can configure in application.properties or application.yml:

  1. dubbo.application.qos-enable=true
  2. dubbo.application.qos-port=33333
  3. dubbo.application.qos-accept-foreign-ip=false
  4. dubbo.application.qos-accept-foreign-ip-whitelist=123.12.10.13, 132.12.10.13/24
  5. dubbo.application.qos-anonymous-access-permission-level=NONE

Feedback

Was this page helpful?

Yes No

Last modified September 30, 2024: Update & Translate Overview Docs (#3040) (d37ebceaea7)