Nacos 2.4.3 登录配置

article/2025/6/24 2:41:41

1, 调整配置

在这里插入图片描述

完整配置文件

#
# Copyright 1999-2021 Alibaba Group Holding Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##*************** Spring Boot Related Configurations ***************#
### Default web context path:
server.servlet.contextPath=/nacos
### Include message field
server.error.include-message=ALWAYS
### Default web server port:
server.port=8848#*************** Network Related Configurations ***************#
### If prefer hostname over ip for Nacos server addresses in cluster.conf:
# nacos.inetutils.prefer-hostname-over-ip=false### Specify local server's IP:
# nacos.inetutils.ip-address=#*************** Config Module Related Configurations ***************#
### If use MySQL as datasource:
### Deprecated configuration property, it is recommended to use `spring.sql.init.platform` replaced.
# spring.datasource.platform=mysql
# spring.sql.init.platform=mysql### Count of DB:
# db.num=1### Connect URL of DB:
# db.url.0=jdbc:mysql://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
# db.user.0=nacos
# db.password.0=nacos### Connection pool configuration: hikariCP
db.pool.config.connectionTimeout=30000
db.pool.config.validationTimeout=10000
db.pool.config.maximumPoolSize=20
db.pool.config.minimumIdle=2### the maximum retry times for push
nacos.config.push.maxRetryTime=50#*************** Naming Module Related Configurations ***************#### If enable data warmup. If set to false, the server would accept request without local data preparation:
# nacos.naming.data.warmup=true### If enable the instance auto expiration, kind like of health check of instance:
# nacos.naming.expireInstance=true### Add in 2.0.0
### The interval to clean empty service, unit: milliseconds.
# nacos.naming.clean.empty-service.interval=60000### The expired time to clean empty service, unit: milliseconds.
# nacos.naming.clean.empty-service.expired-time=60000### The interval to clean expired metadata, unit: milliseconds.
# nacos.naming.clean.expired-metadata.interval=5000### The expired time to clean metadata, unit: milliseconds.
# nacos.naming.clean.expired-metadata.expired-time=60000### The delay time before push task to execute from service changed, unit: milliseconds.
# nacos.naming.push.pushTaskDelay=500### The timeout for push task execute, unit: milliseconds.
# nacos.naming.push.pushTaskTimeout=5000### The delay time for retrying failed push task, unit: milliseconds.
# nacos.naming.push.pushTaskRetryDelay=1000### Since 2.0.3
### The expired time for inactive client, unit: milliseconds.
# nacos.naming.client.expired.time=180000#*************** CMDB Module Related Configurations ***************#
### The interval to dump external CMDB in seconds:
# nacos.cmdb.dumpTaskInterval=3600### The interval of polling data change event in seconds:
# nacos.cmdb.eventTaskInterval=10### The interval of loading labels in seconds:
# nacos.cmdb.labelTaskInterval=300### If turn on data loading task:
# nacos.cmdb.loadDataAtStart=false#***********Metrics for tomcat **************************#
server.tomcat.mbeanregistry.enabled=true#***********Expose prometheus and health **************************#
#management.endpoints.web.exposure.include=prometheus,health### Metrics for elastic search
management.metrics.export.elastic.enabled=false
#management.metrics.export.elastic.host=http://localhost:9200### Metrics for influx
management.metrics.export.influx.enabled=false
#management.metrics.export.influx.db=springboot
#management.metrics.export.influx.uri=http://localhost:8086
#management.metrics.export.influx.auto-create-db=true
#management.metrics.export.influx.consistency=one
#management.metrics.export.influx.compressed=true#*************** Access Log Related Configurations ***************#
### If turn on the access log:
server.tomcat.accesslog.enabled=true### file name pattern, one file per hour
server.tomcat.accesslog.rotate=true
server.tomcat.accesslog.file-date-format=.yyyy-MM-dd-HH
### The access log pattern:
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i### The directory of access log:
server.tomcat.basedir=file:.#*************** Access Control Related Configurations ***************#
### If enable spring security, this option is deprecated in 1.2.0:
#spring.security.enabled=false### The ignore urls of auth
nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**### The auth system to use, currently only 'nacos' and 'ldap' is supported:
nacos.core.auth.system.type=nacos### If turn on auth system:
nacos.core.auth.enabled=true### Turn on/off caching of auth information. By turning on this switch, the update of auth information would have a 15 seconds delay.
nacos.core.auth.caching.enabled=true### Since 1.4.1, Turn on/off white auth for user-agent: nacos-server, only for upgrade from old version.
nacos.core.auth.enable.userAgentAuthWhite=false### Since 1.4.1, worked when nacos.core.auth.enabled=true and nacos.core.auth.enable.userAgentAuthWhite=false.
### The two properties is the white list for auth and used by identity the request from other server.
nacos.core.auth.server.identity.key=nacos
nacos.core.auth.server.identity.value=123456### worked when nacos.core.auth.system.type=nacos
### The token expiration in seconds:
nacos.core.auth.plugin.nacos.token.cache.enable=false
nacos.core.auth.plugin.nacos.token.expire.seconds=18000
### The default token (Base64 String):
nacos.core.auth.plugin.nacos.token.secret.key=BmqRJWXrYAfPQftpbNSj+AbY1Oz56V605ycm85WIK1E=### worked when nacos.core.auth.system.type=ldap,{0} is Placeholder,replace login username
#nacos.core.auth.ldap.url=ldap://localhost:389
#nacos.core.auth.ldap.basedc=dc=example,dc=org
#nacos.core.auth.ldap.userDn=cn=admin,${nacos.core.auth.ldap.basedc}
#nacos.core.auth.ldap.password=admin
#nacos.core.auth.ldap.userdn=cn={0},dc=example,dc=org
#nacos.core.auth.ldap.filter.prefix=uid
#nacos.core.auth.ldap.case.sensitive=true
#nacos.core.auth.ldap.ignore.partial.result.exception=false#*************** Control Plugin Related Configurations ***************#
# plugin type
#nacos.plugin.control.manager.type=nacos# local control rule storage dir, default ${nacos.home}/data/connection and ${nacos.home}/data/tps
#nacos.plugin.control.rule.local.basedir=${nacos.home}# external control rule storage type, if exist
#nacos.plugin.control.rule.external.storage=#*************** Config Change Plugin Related Configurations ***************#
# webhook
#nacos.core.config.plugin.webhook.enabled=false
# It is recommended to use EB https://help.aliyun.com/document_detail/413974.html
#nacos.core.config.plugin.webhook.url=http://localhost:8080/webhook/send?token=***
# The content push max capacity ,byte
#nacos.core.config.plugin.webhook.contentMaxCapacity=102400# whitelist
#nacos.core.config.plugin.whitelist.enabled=false
# The import file suffixs
#nacos.core.config.plugin.whitelist.suffixs=xml,text,properties,yaml,html
# fileformatcheck,which validate the import file of type and content
#nacos.core.config.plugin.fileformatcheck.enabled=false#*************** Istio Related Configurations ***************#
### If turn on the MCP server:
nacos.istio.mcp.server.enabled=false#*************** Core Related Configurations ***************#### set the WorkerID manually
# nacos.core.snowflake.worker-id=### Member-MetaData
# nacos.core.member.meta.site=
# nacos.core.member.meta.adweight=
# nacos.core.member.meta.weight=### MemberLookup
### Addressing pattern category, If set, the priority is highest
# nacos.core.member.lookup.type=[file,address-server]
## Set the cluster list with a configuration file or command-line argument
# nacos.member.list=192.168.16.101:8847?raft_port=8807,192.168.16.101?raft_port=8808,192.168.16.101:8849?raft_port=8809
## for AddressServerMemberLookup
# Maximum number of retries to query the address server upon initialization
# nacos.core.address-server.retry=5
## Server domain name address of [address-server] mode
# address.server.domain=jmenv.tbsite.net
## Server port of [address-server] mode
# address.server.port=8080
## Request address of [address-server] mode
# address.server.url=/nacos/serverlist#*************** JRaft Related Configurations ***************#### Sets the Raft cluster election timeout, default value is 5 second
# nacos.core.protocol.raft.data.election_timeout_ms=5000
### Sets the amount of time the Raft snapshot will execute periodically, default is 30 minute
# nacos.core.protocol.raft.data.snapshot_interval_secs=30
### raft internal worker threads
# nacos.core.protocol.raft.data.core_thread_num=8
### Number of threads required for raft business request processing
# nacos.core.protocol.raft.data.cli_service_thread_num=4
### raft linear read strategy. Safe linear reads are used by default, that is, the Leader tenure is confirmed by heartbeat
# nacos.core.protocol.raft.data.read_index_type=ReadOnlySafe
### rpc request timeout, default 5 seconds
# nacos.core.protocol.raft.data.rpc_request_timeout_ms=5000#*************** Distro Related Configurations ***************#### Distro data sync delay time, when sync task delayed, task will be merged for same data key. Default 1 second.
# nacos.core.protocol.distro.data.sync.delayMs=1000### Distro data sync timeout for one sync data, default 3 seconds.
# nacos.core.protocol.distro.data.sync.timeoutMs=3000### Distro data sync retry delay time when sync data failed or timeout, same behavior with delayMs, default 3 seconds.
# nacos.core.protocol.distro.data.sync.retryDelayMs=3000### Distro data verify interval time, verify synced data whether expired for a interval. Default 5 seconds.
# nacos.core.protocol.distro.data.verify.intervalMs=5000### Distro data verify timeout for one verify, default 3 seconds.
# nacos.core.protocol.distro.data.verify.timeoutMs=3000### Distro data load retry delay when load snapshot data failed, default 30 seconds.
# nacos.core.protocol.distro.data.load.retryDelayMs=30000### enable to support prometheus service discovery
#nacos.prometheus.metrics.enabled=true### Since 2.3
#*************** Grpc Configurations ***************### sdk grpc(between nacos server and client) configuration
## Sets the maximum message size allowed to be received on the server.
#nacos.remote.server.grpc.sdk.max-inbound-message-size=10485760## Sets the time(milliseconds) without read activity before sending a keepalive ping. The typical default is two hours.
#nacos.remote.server.grpc.sdk.keep-alive-time=7200000## Sets a time(milliseconds) waiting for read activity after sending a keepalive ping. Defaults to 20 seconds.
#nacos.remote.server.grpc.sdk.keep-alive-timeout=20000## Sets a time(milliseconds) that specify the most aggressive keep-alive time clients are permitted to configure. The typical default is 5 minutes
#nacos.remote.server.grpc.sdk.permit-keep-alive-time=300000## cluster grpc(inside the nacos server) configuration
#nacos.remote.server.grpc.cluster.max-inbound-message-size=10485760## Sets the time(milliseconds) without read activity before sending a keepalive ping. The typical default is two hours.
#nacos.remote.server.grpc.cluster.keep-alive-time=7200000## Sets a time(milliseconds) waiting for read activity after sending a keepalive ping. Defaults to 20 seconds.
#nacos.remote.server.grpc.cluster.keep-alive-timeout=20000## Sets a time(milliseconds) that specify the most aggressive keep-alive time clients are permitted to configure. The typical default is 5 minutes
#nacos.remote.server.grpc.cluster.permit-keep-alive-time=300000## open nacos default console ui
#nacos.console.ui.enabled=true

2,创建Nacos登录账号和密码,生成 32 字节的随机密钥

PS: 如果没有引入Nacos依赖,先引入Nacos依赖

package com.xcmd.shop.platform.model;import com.alibaba.fastjson.JSON;
import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.NamingService;import java.security.SecureRandom;
import java.util.Base64;
import java.util.Properties;/*** @author jlyang* @date 2025/6/2 11:12* @description:*/
public class NacosAuth {public static void main(String[] args) {createNacosAuth();getBase64SecretKey();}/*** 获取 Base64 编码的密钥*/private static void getBase64SecretKey() {// 生成 32 字节的随机密钥byte[] secretKeyBytes = new byte[32];SecureRandom secureRandom = new SecureRandom();secureRandom.nextBytes(secretKeyBytes);// 将字节数组编码为 Base64 字符串String base64SecretKey = Base64.getEncoder().encodeToString(secretKeyBytes);System.out.println("Generated Base64 Encoded Secret Key:");// 把这个密钥放在 nacos.core.auth.plugin.nacos.token.secret.key=System.out.println(base64SecretKey);}/*** 创建 Nacos 鉴权*/private static void createNacosAuth() {try {// Nacos 服务器地址(替换为实际地址)String serverAddr = "127.0.0.1:8848";Properties properties = new Properties();properties.put("serverAddr", serverAddr);// 如果需要鉴权// nacos.core.auth.server.identity.key=nacosproperties.put("username", "nacos");// nacos.core.auth.server.identity.value=123456properties.put("password", "123456");// 初始化配置服务ConfigService configService = NacosFactory.createConfigService(properties);System.out.println("configService" + JSON.toJSONString(configService));// 初始化命名服务NamingService namingService = NacosFactory.createNamingService(properties);System.out.println("namingService" + JSON.toJSONString(namingService));System.out.println("Nacos services initialized successfully!");} catch (NacosException e) {e.printStackTrace();}}
}

3. 重启Nacos

执行命令:startup.cmd -m standalone
在这里插入图片描述

4. 访问Nacos的启动地址

访问地址:输入设置好的账号和密码,点“提交”按钮

http://192.168.2.14:8848/nacos/index.html#/login

在这里插入图片描述
登录成功
在这里插入图片描述
重新修改密码
在这里插入图片描述

5. 程序访问时需配置账号和密码

在配置文件中添加

username: nacos # Nacos 账号
password: 123456 # Nacos 密码

在这里插入图片描述
参考官网配置鉴权:(https://nacos.io/docs/next/manual/user/auth/)


http://www.hkcw.cn/article/nDTeDwcNcY.shtml

相关文章

Cursor 0.51 全网首歌新功能深度体验:Generate Memories 让 AI 编程助手拥有“记忆“

写在前面 你是否遇到过这样的困扰:每次开启新的 Cursor 对话,都要重新向 AI 解释项目背景、技术栈、架构设计?或者当对话内容过多时,AI 就"忘记"了之前讨论的重要信息? 如果你有过这样的经历,那么 Cursor 0.51 版本新推出的 Generate Memories 功能绝对是你的…

如何在WHM中配置远程数据库访问

在远程数据库访问方面,cPanel和WHM之间存在一些差异: 在WHM中添加的主机将应用于所有cPanel用户帐户及其关联的MySQL用户。 cPanel用户无法永久删除由系统管理员root账户在WHM中添加的主机。 要允许远程主机访问MySQL数据库,请导航到侧边栏…

强大的PDF编辑工具,操作方便 ,长久使用

这是一款能够让每一个用户都能在这里轻松实现最简单的编辑方式,一站式完成PDF文件处理,较于前面几个版本,这个版本整体界面比较清爽,用户可以在这里一站式完成PDF编辑,在这里快速修改,编辑、创建、电子签名…

上海迪士尼游客打架官方通报 拍照冲突致肢体冲突

昨天21:45,浦东公安分局发布微博称,5月31日18时许接到报警,迪士尼乐园内发生打架事件。经初步调查,闫某某(男,22岁)与女友在拍照时,因刘某某(男,36岁)夫妻的女儿进入拍摄画面,双方发生口角后引发肢体冲突,造成闫某某和刘某某互有皮外伤,小女孩未受伤。目前,调查…

蔚来5月交付23231辆 同比增长13.1%

6月1日,蔚来公司公布了5月份的交付数据。当月共交付新车23231台,同比增长13.1%。具体来看,蔚来品牌交付了13270台;乐道品牌交付了6281台;firefly萤火虫品牌交付了3680台。截至目前,蔚来公司累计交付新车总数达到760789台。其中,蔚来品牌累计交付710655台;乐道品牌累计交…

沈白高铁进入开通运营倒计时 联调联试启动

6月1日,国家“十四五”规划重点高速铁路建设项目——沈阳至长白山高速铁路正式启动联调联试,标志着沈白高铁进入开通运营的倒计时。沈白高铁起自沈阳北站,途经辽宁省沈阳市、沈抚新区、抚顺市,以及吉林省通化市、白山市、延边州、长白山管委会,最终引入敦化至白河铁路长白…

台艺人刘乐妍称自己是中国人:反对"台独"是世界潮流,也是台湾唯一出路

六一发文称自己是中国人!台湾艺人刘乐妍:反对"台独"是世界潮流,也是台湾唯一出路!责任编辑:zx0002

Cesium使用primitive添加点线面(贴地)

// 创建一个图元集合const primitives viewer.scene.primitives.add(new Cesium.PrimitiveCollection());1、点上图 // 定义点的位置(中国不同城市的经纬度)const points [{ lon: 116.4074, lat: 39.9042, name: "北京" },{ lon: 121.4737, …

杨明洋社媒晒国足训练照 备战印尼全力以赴

国脚杨明洋更新了社交媒体,分享了自己随国足备战与印尼比赛的照片。国足目前在上海进行最后两场18强赛的备战工作,并计划于今日启程前往雅加达。杨明洋表示,首次入选国家队感到非常荣幸,能够成为其中一员对他来说意义重大。责任编辑:zx0176

警方通报上海迪士尼打架事件 拍照争执引发冲突

6月1日,浦东公安分局接到报警称,5月31日18时许迪士尼乐园内有人打架。经初步调查,闫某某(男,22岁)与女友在拍照时,因刘某某(男,36岁)夫妻的女儿进入拍摄画面,双方发生口角后引发肢体冲突,造成闫某某和刘某某互有皮外伤,小女孩未受伤。目前,调查处理工作正在进一步…

机器视觉图像处理之图像滤波

1.均值滤波 均值滤波是一种基本的线性图像滤波方法,主要用于图像平滑和噪声去除。 特点 优点: 算法简单,计算速度快 对高斯噪声有较好的去除效果 能有效平滑图像中的小波动 缺点: 会导致边缘模糊 对椒盐噪声(脉冲噪声)效果不…

8、电解电容—数据手册解读

目录 1、寿命 2、Rated Voltage 额定电压(VR) 3、Capacitance 额定容量(CR) 4、Surge Voltage 浪涌电压(VS) 5、Leakage Current 泄漏电流(ILC) 6、Dissipation Factor (Tanδ)损失角正切值 7、Ripple Current 纹波电流(IRC, rms) 8、参数特性 9、寿命计算 9.1 以江海为例&…

Python----目标检测(《YOLOv3:AnIncrementalImprovement》和YOLO-V3的原理与网络结构)

一、《YOLOv3:AnIncrementalImprovement》 1.1、基本信息 标题:YOLOv3: An Incremental Improvement 作者:Joseph Redmon, Ali Farhadi 机构:华盛顿大学(University of Washington) 发表时间:2018年 代…

ck-editor5的研究 (5):优化-页面离开时提醒保存,顺便了解一下 Editor的生命周期 和 6大编辑器类型

前言 经过前面的 4 篇内容,我们已经慢慢对 CKEditor5 熟悉起来了。这篇文章,我们就来做一个优化,顺便再补几个知识点: 当用户离开时页面时,提醒他保存数据了解一下 CKEditor5 的 六大编辑器类型了解一下 editor 实例对…

unity开发棋牌游戏

使用unity开发的棋牌游戏,目前包含麻将、斗地主、比鸡、牛牛四种玩法游戏。 相关技术 客户端:unity 热更新:xlua 服务器:c Web服务器:ruoyi 游戏视频 unity开发棋牌游戏 游戏截图

2025GDCPC广东省赛游记(附赛时代码)

我觉得算是给swan的自证之旅画上一个句号吧...说实话HDU给我带来的不止是排位上的压力,更多的是对自己能力的怀疑,特别是pluto不明说但是我很清楚的看不起(没有责备本人的意思),evil和jxj之类的总感觉看到我就是看小丑…

元器件基础学习笔记——双极结型晶体管 (BJT)

一、概述 1.1 基本结构 双极结型晶体管(Bipolar Junction Transistor)由发射极(Emitter)、基极(Base)和集电极(Collector)三个掺杂程度不同的半导体区域组成,分别对应有…

2024最新DEM数据

数据简介 今天我们分享的数据是在2024年最新更新的全球DEM数据,并将其裁剪成中国区域以及各个省份与各个城市的数据,方便大家研究使用。 该数据来源于GEBCO,GEBCO是一个由测绘专家组成的国际小组,在国际水文组织(IHO&a…

小车冲进屋10岁姐姐神速救起妹妹 惊险瞬间化险为夷

小车冲进屋10岁姐姐神速救起妹妹 惊险瞬间化险为夷!老头乐作为一款低速电车,深受广大百姓的喜爱,甚至一些年轻人也对这种小车子爱不释手。然而,随着老头乐的不断发展,一些问题也随之而来,有些厂家甚至制造出了“老头乐半挂”,让人感到非常离谱。人们并不是讨厌这种车子,…

杨天真发视频回应留学争议 活出所有可能性

杨天真发视频回应留学争议 活出所有可能性。6月1日,壹心娱乐的杨天真在社交媒体上发文回应了她“出国留学”的消息。她表示:“我为什么去留学?用人生给自己写一封情书。为什么总是在改变?因为我渴望在有限的人生里活出所有的可能性。”杨天真在发布的视频中提到,由于长期不…