2023-06-17
681
m1芯片使用docker不方便,嫌弃占用高,因此使用vps的docker daemon,客户端只需要安装docker-cli服务端1.生成CA私钥文件ca-key.pemopenssl genrsa -aes256 -out ca-key.pem 40962.生成CA公钥文件ca.pemopenssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem3.基于CA文件生成server-key.pem文件openssl genrsa -out server-key.pem 40964.基于server-key.pem文件生成server.csr文件openssl req -subj "/CN=192.168.22.65" -sha256 -new -key server-key.pem -out server.csr注意:生成过程中Common Name填写主机IP:192.168.22.655.输出subjectAltName属性到extfile.cnf文件2选1echo subjectAltName = DNS:$HOST,IP:192.168.22.65,IP:127.0.0.1 extfile.cnfecho subjectAltName = IP:192.168.22.65,IP:0.0.0.0 extfile.cnf注意:TLS连接可以通过域名或IP建立,所以这里DNS:$HOST中的$HOST应填写你的域名。但我的需求是docker主机本机和客户端主机能够访问就可以了192.168.22.65为服务端ip6.输出extendedKeyUsage属性到extfile.cnf文件echo extendedKeyUsage = serverAuth extfile.cnf7.生成签名证书server-cert.pem文件openssl x509 -req -days 365 -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out server-cert.pem -extfile extfile.cnf8.创建客户端私钥文件key.pemopenssl genrsa -out key.pem 40969.基于key.pem文件生成client.csr文件openssl req -subj '/CN=client' -new -key key.pem -out client.csr10.输出extendedKeyUsage属性到extfile-client.cnf文件echo extendedKeyUsage = clientAuth extfile-client.cnf11.生成签名证书cert.pem文件openssl x509 -req -days 365 -sha256 -in client.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out cert.pem -extfile extfile-client.cnf12.删除两个csr文件和extfile文件rm -v client.csr server.csr extfile.cnf extfile-client.cnf13.修改**文件权限为只允许所有者读取chmod -v 0400 ca-key.pem key.pem server-key.pem14.修改证书文件权限为只读chmod -v 0444 ca.pem server-cert.pem cert.pem15.将CA证书、服务端证书、服务端**文件拷贝到/etc/docker目录cp -v ca.pem server-cert.pem server-key.pem /etc/docker16.配置/etc/docker/daemon.json文件{ "tlsverify": true, "tlscacert": "/etc/docker/ca.pem", "tlscert": "/etc/docker/server-cert.pem", "tlskey": "/etc/docker/server-key.pem", "hosts": ["tcp://0.0.0.0:2376","unix:///var/run/docker.sock"], "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]}17.修改/lib/systemd/system/docker.service文件中的配置ExecStart = /usr/bin/dockerd最后重启dockersystemctl daemon-reload systemctl restart docker客户端将CA证书、客户端证书、客户端**文件拷贝到/root/.docker目录cp -v ca.pem cert.pem key.pem /root/.docker设置环境变变量export DOCKER_HOST=tcp://192.168.22.65:2376export DOCKER_TLS_VERIFY=1转载自:https://blog.csdn.net/wendrewshay/article/details/88255002?spm=1001.2014.3001.5502
继续阅读»
2022-12-08
706
1.下载Zipkin服务端(jar包)https://search.maven.org/remote_content?g=io.zipkina=zipkin-serverv=LATESTc=exec2.运行Zipkin服务端,看到如下提示就对了,默认将记录数据存在内存中。zxq@ZXQdeMacBook-Air Desktop % java -jar zipkin-server-2.23.19-exec.jar oo oooo oooooo oooooooo oooooooooo oooooooooooo ooooooo ooooooo oooooo ooooooo oooooo ooooooo oooooo o o oooooo oooooo oo oo oooooo ooooooo oooo oooo ooooooo oooooo ooooo ooooo ooooooo oooooo oooooo oooooo ooooooo oooooooo oo oo oooooooo ooooooooooooo oo oo ooooooooooooo oooooooooooo oooooooooooo oooooooo oooooooo oooo oooo ________ ____ _ _____ _ _ |__ /_ _| _ \| |/ /_ _| \ | | / / | || |_) | ' / | || \| | / /_ | || __/| . \ | || |\ | |____|___|_| |_|\_\___|_| \_|:: version 2.23.19 :: commit 0831f9b ::2022-12-08 14:42:57.168 INFO [/] 3936 --- [oss-http-*:9411] c.l.a.s.Server : Serving HTTP at /0:0:0:0:0:0:0:0:9411 - http://127.0.0.1:9411/3.在要记录调用链的服务中 properties spring-cloud.version2021.0.5/spring-cloud.version /properties dependencies dependency groupIdorg.springframework.cloud/groupId artifactIdspring-cloud-starter-sleuth/artifactId /dependency !-- zipkin -- dependency groupIdorg.springframework.cloud/groupId artifactIdspring-cloud-sleuth-zipkin/artifactId /dependency /dependencies dependencyManagement dependencies dependency groupIdorg.springframework.cloud/groupId artifactIdspring-cloud-dependencies/artifactId version${spring-cloud.version}/version typepom/type scopeimport/scope /dependency /dependencies /dependencyManagementyml:spring: sleuth: sampler: probability: 1.0 zipkin: base-url: http://127.0.0.1:9411 sender: type: web遇到个yml文件读取不到pom.xml中的变量问题,因为将mapper放在java目录下,配置了 resources resource directorysrc/main/java/directory includes include**/*.xml/include /includes /resource resource directorysrc/main/resources/directory /resourceresources导致读取失败,在src/main/resources下配置filtering即可 resource directorysrc/main/resources/directory filteringtrue/filtering /resource参考:https://spring.io/projects/spring-cloud-sleuth#overviewhttps://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html
继续阅读»
2021-10-16
856
首先下载解压版Tomcat,解压多个tomcat然后修改文件夹名:[图片]每个tomcat做如下操作:1. 环境变量(不需要)设置CATALINA_HOME1为tomcat1的目录设置CATALINA_BASE1为tomcat1的目录2. 进入conf文件夹,修改server.xml中的8080,8005,8009端口3. 替换CATALINA_HOME及CATALINA_BASE进入tomcat1的bin目录,将catalina.bat,startup.bat,service.bat进行如下替换替换CATALINA_HOME为CATALINA_HOME1替换CATALINA_BASE为CATALINA_BASE1替换完成后,在bin目录下执行cmd命令./service.bat install你的tomcat服务名如下提示代表安装成功,执行netstarttomcat服务名 即可启动tomcat[图片]在服务列表中可以看到刚刚安装的服务:[图片]记录: jenkins部署至tomcat默认项目时,需将默认的ROOT文件夹删掉,context path填/而不是/ROOT,否则报错:java.net.SocketException: Software caused connection abort: recv failed[图片]
继续阅读»
2021-08-12
1016
Let's Encrypt提供免费https证书,可通过certbot进行在线证书颁发,颁发时需认证域名所有者,可通过webroot、txt解析方式认证Webrootwebroot方式即CertBot通过访问颁发证书的服务器的以下路径example.com/.well-known/acme-challenge/xxx,进行授权认证,其中xxx为certbot随机生成的值,生成在/data/letsencrypt (可通过-w参数指定),因此使用docker时需要将/data/letsencrypt挂载至宿主机,并配置允许nginx访问该内容,注意若nginx的/路径已经配置其他服务,应该将/.well-know配置在该server下,否则路径匹配不会成功server { listen 80; server_name zhangxiaoqiang.top www.zhangxiaoqiang.top; root /usr/share/nginx/html; index index.html; location / { proxy_pass http://172.16.1.80:8080/; } location ^~ /.well-known { alias /home/certbot/au/.well-known; } }命令如下:docker run -it --rm --name certbot -v "/home/certbot:/etc/letsencrypt" -v "/home/certbot:/var/lib/letsencrypt" -v "/home/certbot/au:/data/letsencrypt" -v "/home/certbot/log:/var/log/letsencrypt" certbot/certbot certonly -d a.zhangxiaoqiang.top --agree-tos -m 1711764827@qq.com --webroot -w /data/letsencrypt -v其中:-d用于指定生成证书的域名--webroot:验证方式使用webroot--agree-tos:同意他的协议-w/--webroot-path:站点目录,即生成xxx认证文件的路径,这个路径为容器中的路径,请注意宿主机nginx配置,不正确配置宿主机nginx将无法访问认证文件导致认证失败-m:邮箱,证书过期了会通知到该邮箱TXTtxt方式认证支持生成泛解析域名的证书,及域名颁发给*.example.com,首先在这里选择certbot官方提供的对应的解析服务商文档:https://certbot.eff.org/docs/using.html#dns-plugins利用certbot官方提供的docker镜像自动配置cloudflare的txt解析,去这里寻找你对应的域名DNS解析商的docker镜像:https://hub.docker.com/u/certbot/按照官方文档,去解析服务商生成一个secreat或者api-token,这里以cloudflare为例,官方说明如下:https://certbot-dns-cloudflare.readthedocs.io/en/stable/命令如下:docker run -it --rm --name certbot -v "/home/certbot:/etc/letsencrypt" -v "/home/certbot:/var/lib/letsencrypt" -v "/home/certbot/au:/data/letsencrypt" -v "/home/certbot/log:/var/log/letsencrypt" certbot/dns-cloudflare certonly -d *.zhangxiaoqiang.top --agree-tos -m 1711764827@qq.com --preferred-challenges dns --dns-cloudflare --dns-cloudflare-credentials /etc/letsencrypt/cloudflare.ini --server https://acme-v02.api.letsencrypt.org/directory其中:--preferred-challenges dns指定使用dns方式验证域名所有者--dns-cloudflare指定解析服务商是cloudflare--dns-cloudflare-credentials /etc/letsencrypt/cloudflare.ini 指定包含secret文件,解析服务商不同参数名也不同,注意docker挂载, secret在解析服务商生成--server https://acme-v02.api.letsencrypt.org/directory 颁发泛解析域名需要指定这个server,默认的server只能颁发单个域名的证书颁发成功后证书会在容器/etc/letsencrypt/live对应的域名文件夹中,请对应查看宿主机位置注Let's Encrypt限制了每个域名颁发证书频率,调试时可加上 --dry-run 参数使用官方提供的测试环境颁发证书官方说明如下:https://letsencrypt.org/zh-cn/docs/rate-limits/可以写一个脚本定时重新颁发证书,后面再研究crontab -e放入以下内容添加 0 3 */7 * * /home/docker/certbot/autorenew.sh /home/docker/certbot/log表示从今天开始每隔7天晚上3点执行任务autorenew.sh脚本内容如下#!/bin/bashrm -rf /etc/nginx/cert/live/rm -rf /etc/nginx/cert/archive/docker run --rm --name certbot -v "/etc/nginx/cert/live/:/etc/letsencrypt/live/" -v "/etc/nginx/cert/archive/:/etc/letsencrypt/archive/" -v "/home/docker/certbot/cloudflare.ini:/cloudflare.ini" certbot/dns-cloudflare certonly -d *.zhangxiaoqiang.top --agree-tos -m 1711764827@qq.com --preferred-challenges dns --dns-cloudflare --dns-cloudflare-credentials /cloudflare.ini --server https://acme-v02.api.letsencrypt.org/directory --no-eff-emailsleep 100snginx -s reload这里注意不能使用交互模式运行容器(-it), crontab计划任务是无法进入任何终端的参考资料:https://certbot.eff.org/docs/using.html?highlight=webroot#webroothttps://www.cnblogs.com/txb1989/p/13079961.htmlhttps://www.jianshu.com/p/1eb7060c5ede?utm_campaign=maleskineutm_content=noteutm_medium=seo_notesutm_source=recommendationhttps://www.cnblogs.com/jpfss/p/10232980.html
继续阅读»