记录日常工作关于系统运维,虚拟化云计算,数据库,网络安全等各方面问题。

Docker 或k8s部署 NACOS开启登录

一,修改 Nacos 主目录 config/application.properties 文件

 

(1)启动登录认证功能 原本是 false 修改为 true。

 

### If turn on auth system:
nacos.core.auth.enabled=``true

 

(2)客户端和服务端交互时用于加密的密钥,可以防止认证过程中的信息泄露。

 

### 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=yourKey 
nacos.core.auth.server.identity.value=yourKey

 

 

注意:yourKey 就是秘钥,根据自己需求填写。

(3)设置 Token 认证的密钥

 

### The default token (Base64 String):
nacos.core.auth.plugin.nacos.token.secret.key=VGhpc0lzTXlDdXN0b21TZWNyZXRLZXkwMTIzNDU2Nzg=

 

注意:这里设置的秘钥长度必须大于等于 32 字节,并且使用 Base64 加密,例如:VGhpc0lzTXlDdXN0b21TZWNyZXRLZXkwMTIzNDU2Nzg= 实际字符串为 ThisIsMyCustomSecretKey012345678

(4)重启 Nacos 服务。

 

二,以下是docker 与k8s运行nacos时的参数

 

Common property configuration

namedescriptionoption
MODEcluster/standalonecluster/standalone default cluster
NACOS_SERVERSnacos cluster addresseg. ip1:port1 ip2:port2 ip3:port3
PREFER_HOST_MODEWhether hostname are supportedhostname/ip default ip
NACOS_APPLICATION_PORTnacos server portdefault 8848
NACOS_SERVER_IPcustom nacos server ip when network was mutil-network 
SPRING_DATASOURCE_PLATFORMstandalone support mysqlmysql / empty default empty
MYSQL_SERVICE_HOSTmysql host 
MYSQL_SERVICE_PORTmysql database portdefault : 3306
MYSQL_SERVICE_DB_NAMEmysql database name 
MYSQL_SERVICE_USERusername of database 
MYSQL_SERVICE_PASSWORDpassword of database 
MYSQL_DATABASE_NUMIt indicates the number of databasedefault :1
MYSQL_SERVICE_DB_PARAMDatabase url parameterdefault : characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false
JVM_XMS-Xmsdefault :1g
JVM_XMX-Xmxdefault :1g
JVM_XMN-Xmndefault :512m
JVM_MS-XX:MetaspaceSizedefault :128m
JVM_MMS-XX:MaxMetaspaceSizedefault :320m
NACOS_DEBUGenable remote debugy/n default :n
TOMCAT_ACCESSLOG_ENABLEDserver.tomcat.accesslog.enableddefault :false
NACOS_AUTH_SYSTEM_TYPEThe auth system to use, currently only 'nacos' is supporteddefault :nacos
NACOS_AUTH_ENABLEIf turn on auth systemdefault :false
NACOS_AUTH_TOKEN_EXPIRE_SECONDSThe token expiration in secondsdefault :18000
NACOS_AUTH_TOKENThe default tokendefault :SecretKey012345678901234567890123456789012345678901234567890123456789
NACOS_AUTH_CACHE_ENABLETurn on/off caching of auth information. By turning on this switch, the update of auth information would have a 15 seconds delay.default : false
MEMBER_LISTSet the cluster list with a configuration file or command-line argumenteg:192.168.16.101:8847?raft_port=8807,192.168.16.101?raft_port=8808,192.168.16.101:8849?raft_port=8809
EMBEDDED_STORAGEUse embedded storage in cluster mode without mysqlembedded default : none
NACOS_AUTH_CACHE_ENABLEnacos.core.auth.caching.enableddefault : false
NACOS_AUTH_USER_AGENT_AUTH_WHITE_ENABLEnacos.core.auth.enable.userAgentAuthWhitedefault : false
NACOS_AUTH_IDENTITY_KEYnacos.core.auth.server.identity.keydefault : serverIdentity
NACOS_AUTH_IDENTITY_VALUEnacos.core.auth.server.identity.valuedefault : security
NACOS_SECURITY_IGNORE_URLSnacos.security.ignore.urlsdefault : /,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**



转载请标明出处【Docker 或k8s部署 NACOS开启登录】。

《www.micoder.cc》 虚拟化云计算,系统运维,安全技术服务.

网站已经关闭评论