Compare commits
10 Commits
db71736033
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21ebd55787 | ||
|
|
798bbdf6fe | ||
|
|
7d23a4c38f | ||
|
|
97d8ffa02d | ||
|
|
3bfaefcf0b | ||
|
|
0e32f9f383 | ||
|
|
a873056435 | ||
|
|
e707f856f4 | ||
|
|
6f78361822 | ||
|
|
69135494c6 |
@@ -14,7 +14,11 @@
|
||||
<None Include="$(MSBuildThisFileDirectory)gitea\mysql\config\my.cnf" />
|
||||
<None Include="$(MSBuildThisFileDirectory)gitea\mysql\init\init.sql" />
|
||||
<None Include="$(MSBuildThisFileDirectory)gitea\grant-permissions.sh" />
|
||||
<None Include="$(MSBuildThisFileDirectory)gitea_nodb\docker-compose.yml" />
|
||||
<None Include="$(MSBuildThisFileDirectory)gitea_nodb\grant-permissions.sh" />
|
||||
<None Include="$(MSBuildThisFileDirectory)README2.md" />
|
||||
<None Include="$(MSBuildThisFileDirectory)README.md" />
|
||||
<None Include="$(MSBuildThisFileDirectory)阿里云跨账号ECS互联.docx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="$(MSBuildThisFileDirectory)gitea\mysql\data\" />
|
||||
|
||||
@@ -18,7 +18,7 @@ https://gitea.io/en-us/
|
||||
|
||||
2. 安装docker-compose,参考: <a href="https://www.4spaces.org/centos-install-docker-compose/" target="_blank">CENTOS安装Docker Compose</a>;
|
||||
|
||||
3. 完成NginxAndLetsencrypt的部署;
|
||||
3. 完成NginxAndLetsencrypt的部署(或acme,参看acme项目的实例研究1);
|
||||
|
||||
参见相关说明。(包含把sample.conf改名为gitea.conf或其他名字)
|
||||
|
||||
@@ -28,14 +28,19 @@ https://gitea.io/en-us/
|
||||
|
||||
6. 执行该sh脚本。注意,可以通过tail -2 /etc/passwd和tail -2 /etc/group 查看新注册用户的uid和gid。如和docker-compose.yml中的不符合则应修改yml文件。
|
||||
|
||||
7. 执行 docker inspect nginxdocker_nginx_1 来确定nginx所在网络名称:
|
||||
7. 执行docker ps来查看当前的docker实例,找到其中的nginx实例:
|
||||
|
||||
......
|
||||
84e4e7a719e8 nginx:latest "/bin/sh -c 'while :…" 17 months ago Up 5 weeks 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp **<u>nginx_nginx_1</u>**
|
||||
|
||||
8. 执行 docker inspect nginx_nginx_1来确定nginx所在网络名称:
|
||||
|
||||
```
|
||||
"Networks": {
|
||||
"nginxdocker_default": {
|
||||
"nginx_firstnet": {
|
||||
```
|
||||
|
||||
8. 执行 docker network inspect nginxdocker_default 来确定一些网络信息:
|
||||
9. 执行 docker network inspect nginx_firstnet 来确定一些网络信息:
|
||||
|
||||
```
|
||||
"IPAM": {
|
||||
@@ -43,24 +48,64 @@ https://gitea.io/en-us/
|
||||
"Options": null,
|
||||
"Config": [
|
||||
{
|
||||
"Subnet": "192.168.16.0/20",
|
||||
"Gateway": "192.168.16.1"
|
||||
"Subnet": "172.20.0.0/16"
|
||||
}
|
||||
]
|
||||
},
|
||||
......
|
||||
"Containers": {
|
||||
"84e4e7a719e8a904255ebcb522ce73ff8d0f2340a42d12969cead432ecdf4b77": {
|
||||
"Name": "nginx_nginx_1",
|
||||
"EndpointID": "f7a35255526ed39931e018ad27c2bcc448840f77f4de9666baa4416c396c03a7",
|
||||
"MacAddress": "02:42:ac:14:00:02",
|
||||
"IPv4Address": "172.20.0.2/16",
|
||||
"IPv6Address": ""
|
||||
},
|
||||
"e390b8cbe5075efed7fb834acd74fe7ae84cc685249362b4802abb1e626fc909": {
|
||||
"Name": "frps_server_1",
|
||||
"EndpointID": "04f759a5e894e9286720946763b123f805c76d869697113e83f53e516ed75c4b",
|
||||
"MacAddress": "02:42:ac:14:00:03",
|
||||
"IPv4Address": "172.20.0.3/16",
|
||||
"IPv6Address": ""
|
||||
}
|
||||
},
|
||||
|
||||
```
|
||||
|
||||
9. 根据上述两点网络相关的信息修改gitea的docker-compose文件中的对应部分,并指定固定IP。
|
||||
可以看到,现有的网段和网络中已有实例的IP。我们可以据此规划gitea实例的IP。
|
||||
|
||||
9. 将需要nginx代理的应用设置的固定IP填入之前的gitea.conf。
|
||||
10. 根据上述两点网络相关的信息修改gitea的docker-compose文件中的对应部分,并指定固定IP。
|
||||
|
||||
11. 重启nginx的docker容器。
|
||||
11. 将需要nginx代理的应用设置的固定IP填入之前的gitea.conf。
|
||||
|
||||
12. 重启nginx的docker容器。
|
||||
|
||||
问题发现:重启失败。查看nginx的日志
|
||||
|
||||
- 首先是错误:unknown directive "server"
|
||||
|
||||
[root@ngork logs]# tail -20 error.log
|
||||
2021/10/29 14:01:25 [emerg] 7#7: unknown directive "?server" in /etc/nginx/conf.d/gitwoyue.conf:1
|
||||
|
||||
在开发环境(windows),编码保存为简体中文936解决。原为utf-8。其实,这很奇怪,与一般的认知是相反的。
|
||||
|
||||
- 然后是open() "/etc/letsencrypt/options-ssl-nginx.conf" failed (2: No such file or directory) in /etc/nginx/conf.d/gitwoyue.conf:22
|
||||
|
||||
注释掉即可。
|
||||
|
||||
13. 启动gitea的docker-compose
|
||||
|
||||
`docker-compose up -d`
|
||||
|
||||
14. 访问网站。初始化
|
||||
|
||||
例如,git.woyue.org。
|
||||
|
||||
这里,注意参考用到的compose文件,确认用户名是否需要修改(默认git)
|
||||
|
||||
另外,需要创建一个空的数据库。默认名是gitea。
|
||||
|
||||
12. 启动gitea的docker-compose
|
||||
|
||||
13. ```
|
||||
docker-compose up -d
|
||||
```
|
||||
## 使用说明
|
||||
|
||||
- 配置文件在:/srv/gitea/gitea/gitea/conf下的app.ini
|
||||
@@ -75,3 +120,4 @@ https://gitea.io/en-us/
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
|
||||
29
Gitea/README2.md
Normal file
29
Gitea/README2.md
Normal file
@@ -0,0 +1,29 @@
|
||||
在MH-HP上安装Gitea:
|
||||
先备份wsl:
|
||||
>> wsl --export Ubuntu D:\wsl_backup\gitea_env_backup.tar
|
||||
>>
|
||||
正在导出,这可能需要几分钟时间。 (17396 MB): ./home/hmo/.docker/run/docker-cli-api.sock: pax format cannot archive so (18982 MB)
|
||||
|
||||
操作成功完成。
|
||||
PS C:\WINDOWS\system32> mkdir D:\Gitea_Data
|
||||
>>
|
||||
|
||||
|
||||
目录: D:\
|
||||
|
||||
|
||||
Mode LastWriteTime Length Name
|
||||
---- ------------- ------ ----
|
||||
d----- 2026/2/10 10:47 Gitea_Data
|
||||
|
||||
|
||||
PS C:\WINDOWS\system32> docker run -d `
|
||||
>> --name=gitea `
|
||||
>> --restart=always `
|
||||
>> -p 3000:3000 `
|
||||
>> -p 2222:22 `
|
||||
>> -v D:\Gitea_Data:/data `
|
||||
>> gitea/gitea:latest
|
||||
>>
|
||||
|
||||
现在已经配置完成,可以通过http://git.yoin.fun:8080访问。如何通过frp重定向参看frps项目的README2.md
|
||||
@@ -1,4 +1,4 @@
|
||||
server {
|
||||
server {
|
||||
listen 80;
|
||||
server_name git.woyue.org;
|
||||
server_tokens off;
|
||||
@@ -19,12 +19,12 @@ server {
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/git.woyue.org/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/git.woyue.org/privkey.pem;
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||
#include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
|
||||
|
||||
location / {
|
||||
#ip address below should changed accordingly.
|
||||
proxy_pass http://192.168.16.5:3000;
|
||||
proxy_pass http://172.20.0.15:3000;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
@@ -4,10 +4,10 @@ version: "3.4"
|
||||
networks:
|
||||
gitea:
|
||||
external:
|
||||
name: nginxdocker_default
|
||||
name: nginx_firstnet
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 192.168.16.0/20
|
||||
- subnet: 172.20.0.0/16
|
||||
|
||||
services:
|
||||
server:
|
||||
@@ -23,7 +23,7 @@ services:
|
||||
restart: always
|
||||
networks:
|
||||
gitea:
|
||||
ipv4_address: 192.168.16.15
|
||||
ipv4_address: 172.20.0.15
|
||||
volumes:
|
||||
- ./gitea:/data
|
||||
ports:
|
||||
@@ -42,8 +42,9 @@ services:
|
||||
- MYSQL_DATABASE=gitea
|
||||
networks:
|
||||
gitea:
|
||||
ipv4_address: 192.168.16.14
|
||||
ipv4_address: 172.20.0.14
|
||||
volumes:
|
||||
- ./mysql/config/my.cnf:/etc/my.cnf
|
||||
- ./mysql/data:/var/lib/mysql
|
||||
- ./mysql/init:/docker-entrypoint-initdb.d
|
||||
- /etc/passwd:/etc/passwd #²Î¿¼£ºhttps://blog.csdn.net/qq_23953717/article/details/106668048
|
||||
|
||||
31
Gitea/gitea_nodb/docker-compose.yml
Normal file
31
Gitea/gitea_nodb/docker-compose.yml
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
version: "3.4"
|
||||
|
||||
networks:
|
||||
gitea:
|
||||
external:
|
||||
name: nginx_firstnet
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 172.20.0.0/16
|
||||
|
||||
services:
|
||||
server:
|
||||
image: "gitea/gitea:latest"
|
||||
environment:
|
||||
- USER_UID=1000
|
||||
- USER_GID=1000
|
||||
- DB_TYPE=mysql
|
||||
- DB_HOST=172.18.184.137:3306
|
||||
- DB_NAME=gitea
|
||||
- DB_USER=nrs
|
||||
- DB_PASSWD=Whynotfight
|
||||
restart: always
|
||||
networks:
|
||||
gitea:
|
||||
ipv4_address: 172.20.0.15
|
||||
volumes:
|
||||
- ./gitea:/data
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "222:22"
|
||||
3
Gitea/gitea_nodb/grant-permissions.sh
Normal file
3
Gitea/gitea_nodb/grant-permissions.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
useradd -M -s /sbin/nologin git
|
||||
chown -R git:git ../gitea
|
||||
BIN
Gitea/阿里云跨账号ECS互联.docx
Normal file
BIN
Gitea/阿里云跨账号ECS互联.docx
Normal file
Binary file not shown.
@@ -11,6 +11,7 @@
|
||||
<ItemGroup>
|
||||
<None Include="$(MSBuildThisFileDirectory)docker-compose.yml" />
|
||||
<None Include="$(MSBuildThisFileDirectory)init-letsencrypt.sh" />
|
||||
<None Include="$(MSBuildThisFileDirectory)增加新域名证书%282025-3-7%29.md" />
|
||||
<None Include="$(MSBuildThisFileDirectory)经验汇集.md" />
|
||||
<None Include="$(MSBuildThisFileDirectory)README.md" />
|
||||
<None Include="$(MSBuildThisFileDirectory)sampleApp\docker-compose.yml" />
|
||||
|
||||
@@ -39,18 +39,8 @@ sudo ./init-letsencrypt.sh
|
||||
|
||||
执行init-letsencrypt.sh即可。
|
||||
|
||||
有一些特殊情况,比如配置文件设置了自动对有无www的跳转,http跳转https的,此时可能会失败。应注释掉对所有密钥文件的引用,并确保http能访问得到。
|
||||
|
||||
比如,生产环境ycweb_oc中,可以参考ycweb.conf.whenrequestsslcert。
|
||||
|
||||
例如:ycweb_oc续签实操:
|
||||
|
||||
1. 修改init-letsencrypt.sh中的domain为ycmusic.cn www.ycmusic.cn
|
||||
2. 执行脚本
|
||||
3. 修改init-letsencrypt.sh中的domain为yichao.art www.yichao.art
|
||||
4. 将conf.d/ycweb.conf改名备份,ycweb.conf.whenrequestsslcert改名成ycweb.conf。
|
||||
5. docker restart 【nginx docker实例】
|
||||
6. 执行init-letsencrypt.sh。成功后,把配置文件再改回来。重启nginx docker
|
||||
首先,cd /srv/NginxDocker。然后分别执行init-letsencrypt.sh init-letsencrypt-ycmusic.sh
|
||||
|
||||
## 测试环境
|
||||
|
||||
|
||||
25
NginxAndLetsencrypt/增加新域名证书(2025-3-7).md
Normal file
25
NginxAndLetsencrypt/增加新域名证书(2025-3-7).md
Normal file
@@ -0,0 +1,25 @@
|
||||
# 为新的域名增加证书
|
||||
|
||||
## 相关设备和路径
|
||||
|
||||
1. 用xshell登录120.78.123.183
|
||||
2. `cd /srv #下面有两个子目录,NginxDocker和ycweb。和证书有关的在前者`
|
||||
|
||||
## 申请新证书
|
||||
|
||||
1. NginxDocker下有原有的init-letsencrypt.sh的申请原证书(yichao.art)的脚本。
|
||||
2. `cp init-letsencrypt.sh init-letsencrypt-yoin.sh`
|
||||
3. 修改新文件,把里面的yichao.art替换成新域名(yoin.fun)。
|
||||
4. 执行文件。sh init-letsencrypt-yoin.sh
|
||||
|
||||
## 创建新的nginx配置文件
|
||||
|
||||
1. 在之前目录,执行 `cd server/nginx/conf/conf.d/`
|
||||
2. `cp ycweb.conf yoinweb.conf`
|
||||
3. 编辑新文件,把里面的原有yichao.art全部替换成新域名(yoin.fun)。保存退出
|
||||
4. `docker ps` 列出当前的docker容器。
|
||||
5. `docker restart [ID]` 重启nginx的容器
|
||||
|
||||
## 测试环境
|
||||
|
||||
* CentOS Linux release 7.3.1611 (Core)
|
||||
@@ -4,12 +4,86 @@
|
||||
|
||||
### Docker相关
|
||||
|
||||
```
|
||||
启动 systemctl start docker
|
||||
|
||||
守护进程重启 sudo systemctl daemon-reload
|
||||
|
||||
重启docker服务 systemctl restart docker
|
||||
|
||||
重启docker服务 sudo service docker restart
|
||||
|
||||
关闭docker service docker stop
|
||||
|
||||
关闭docker systemctl stop docker
|
||||
```
|
||||
|
||||
```
|
||||
docker network ls
|
||||
docker network rm 【网络名称】
|
||||
docker inspect 【容器id/名称】
|
||||
docker logs -f -t --since="2017-05-31" --tail=10 【容器名称】 #动态查看容器日志
|
||||
docker logs -f -t --tail=10 【容器名称】 #动态查看容器日志
|
||||
```
|
||||
|
||||
**基础操作:
|
||||
**
|
||||
|
||||
1 **docker images** 查看镜像信息列表 镜像是静态的
|
||||
|
||||
2 **docker ps -a** 查看运行中的所有容器
|
||||
|
||||
3 **docker pull [images]:[version]**从dockerhub拉取指定镜像
|
||||
|
||||
4 **docker run -p 8000:80 -tdi --privileged [imageID] [command]** 后台启动docker,并指定宿主机端口和docker映射端口。
|
||||
|
||||
**-i:**以交互模式运行容器,通常与 -t 同时使用;
|
||||
|
||||
**-d:**后台运行容器,并返回容器ID;
|
||||
|
||||
**-t:**为容器重新分配一个伪输入终端,通常与 -i 同时使用;
|
||||
|
||||
**--privileged** 容器将拥有访问主机所有设备的权限
|
||||
|
||||
通常情况下 [command] 填下 **/bin/bash** 即可。
|
||||
|
||||
特殊情况下,如需要在centos镜像中使用**systemctl** . 则应添加**--privileged** 并设置[command ]为 **init**。
|
||||
|
||||
5 当镜像通过run 启动后,便会载入到一个动态的container(容器)中运行,此时若需要进入终端交互模式:
|
||||
|
||||
**sudo docker exec -it [containerID] /bin/bash**
|
||||
|
||||
交互模式中,使用 ctrl+p+q退出交互 保持运行,使用 exit命令退出并停止容器。
|
||||
|
||||
6 在容器非交互模式下,通过docker start/stop 命令来启动/停止已部署的容器服务。
|
||||
|
||||
7 **docker rm [containerID]** 删除容器
|
||||
|
||||
8 **docker rmi [imageID]** 删除镜像
|
||||
|
||||
9 **docker cp [YourHostFilePath] [containerID]:[DockerPath]** 将宿主机内的指定文件传输至容器内部的指定地址。
|
||||
|
||||
**镜像制作:**
|
||||
|
||||
1 **docker commit [containerID] [ImageName]:[Version]** 将修改后的容器重新打包成镜像
|
||||
|
||||
2 **docker commit -a "runoob.com" -m "my apache" a404c6c174a2 mymysql:v1** 将容器a404c6c174a2 保存为新的镜像,并添加提交人信息和说明信息。
|
||||
|
||||
**-a** :提交的镜像作者;
|
||||
|
||||
**-c** :使用Dockerfile指令来创建镜像;
|
||||
|
||||
**-m** :提交时的说明文字;
|
||||
|
||||
**-p** :在commit时,将容器暂停。
|
||||
|
||||
3 **docker push [ImageID] [repertory_address]**提交镜像到云仓库
|
||||
|
||||
作者:爱睡觉的树
|
||||
链接:https://www.jianshu.com/p/a84e8cf33b34
|
||||
来源:简书
|
||||
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
|
||||
|
||||
### Linux
|
||||
|
||||
```
|
||||
@@ -17,8 +91,20 @@ history #查看历史执行命令
|
||||
tail -n 20 【文件名】#查看文件的后20行
|
||||
du -sh * #查看目录下的磁盘占用情况
|
||||
du -sh * | sort -nr #如上,并排序
|
||||
df -h 查看磁盘空间大小
|
||||
top #linux版本的任务管理器
|
||||
|
||||
chmod u+x ./*.sh
|
||||
|
||||
chmod是权限管理命令change the permissions mode of a file的缩写。。
|
||||
u代表所有者,x代表执行权限。 + 表示增加权限。
|
||||
chmod u+x file.sh 就表示对当前目录下的file.sh文件的所有者增加可执行权限。
|
||||
a+x 是给所有人加上可执行权限,包括所有者,所属组,和其他人
|
||||
o+x 只是给其他人加上可执行权限
|
||||
```
|
||||
|
||||
###
|
||||
|
||||
### Vim
|
||||
|
||||
```
|
||||
@@ -92,7 +178,9 @@ echo
|
||||
environment:
|
||||
|
||||
- MYSQL_ROOT_PASSWORD="mima$$woshimima"
|
||||
|
||||
不过,上面的又有引号又有$的设置是否正确并不确定,因为初次这么设置发现无法登录(通过docker exec -it 进入执行mysql -uroot -p)。
|
||||
|
||||
#### docker-compose中mysql的密码设置
|
||||
|
||||
第一次运行后,只要/var/lib/mysql中的数据没有改变(这通常是因为已经mount到主机的特定目录),那么后续的密码更改是无效的,哪怕把container删了再重建也一样。所以这个时候,要不然用原来密码登录,要不然就是清空data目录。(data目录需要有,不然docker-compose up会失败)
|
||||
115
acme/README.md
115
acme/README.md
@@ -50,15 +50,120 @@
|
||||
|
||||
1. 复制证书:
|
||||
|
||||
mkdir -p /srv/certbot/conf/live/dev.woyue.org
|
||||
场景1:
|
||||
|
||||
acme.sh --installcert -d dev.woyue.org -d *.dev.woyue.org \
|
||||
`mkdir -p /srv/certbot/conf/live/dev.woyue.org`
|
||||
|
||||
`acme.sh --installcert -d dev.woyue.org -d *.dev.woyue.org \
|
||||
--key-file /srv/certbot/conf/live/dev.woyue.org/privkey.pem \
|
||||
--fullchain-file /srv/certbot/conf/live/dev.woyue.org/fullchain.pem \
|
||||
--reloadcmd "docker restart nginxdocker_nginx_1"
|
||||
--reloadcmd "docker restart nginx_nginx_1"`
|
||||
|
||||
注意,最后的nginxdocker_nginx_1为nginx容器的名称。请根据实际情况修改。**或不加此参数,手动重启nginx**。
|
||||
场景2:
|
||||
|
||||
`mkdir -p /srv/certbot/conf/live/nr.woyue.org`
|
||||
|
||||
`acme.sh --installcert -d nr.woyue.org -d *.nr.woyue.org \
|
||||
--key-file /srv/certbot/conf/live/nr.woyue.org/privkey.pem \
|
||||
--fullchain-file /srv/certbot/conf/live/nr.woyue.org/fullchain.pem \
|
||||
--reloadcmd "docker restart nginx_server"`
|
||||
|
||||
注意,最后的nginx_nginx_1或nginx_server为nginx容器的名称。请根据实际情况修改。**或不加此参数,手动重启nginx**。
|
||||
|
||||
2. 生成:dhparams文件
|
||||
|
||||
openssl dhparam -out /srv/certbot/conf/ssl-dhparams.pem 2048
|
||||
`openssl dhparam -out /srv/certbot/conf/ssl-dhparams.pem 2048`
|
||||
|
||||
## 使用证书
|
||||
|
||||
例如,要使用上述证书,则nginx的docker对应etc/letsencrypt的目录就是/srv/certbot/conf。比如说,conf文件里引用的密钥文件路径为:
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/nr.woyue.org/fullchain.pem
|
||||
|
||||
那么,docker mount的路径就应该是:-v /srv/certbot/conf:/etc/letsencrypt
|
||||
|
||||
## 应用实例
|
||||
|
||||
(1)centos2上的证书强制刷新:
|
||||
|
||||
acme.sh --force --debug --issue --dns dns_ali -d nr.woyue.org -d *.nr.woyue.org
|
||||
|
||||
然后,重新执行上述安装指令并重启nginx
|
||||
acme.sh --installcert -d nr.woyue.org -d *.nr.woyue.org \
|
||||
--key-file /srv/certbot/conf/live/nr.woyue.org/privkey.pem \
|
||||
--fullchain-file /srv/certbot/conf/live/nr.woyue.org/fullchain.pem \
|
||||
--reloadcmd "docker restart nginx_server"
|
||||
|
||||
【2021/10/12】前期就已经重新更新失败。经查,依旧是访问某网址时超时的问题。为此,保持windows服务器的小飞机开启再强制重新更新成功。因此,先持续保留,以观察是否能续签成功。
|
||||
|
||||
(2)frps服务器上的acme更新与证书刷新
|
||||
|
||||
记录时间:2021/7/20
|
||||
|
||||
访问网址web.dev.woyue.org,发现证书过期。
|
||||
|
||||
登录服务器,通过acme.sh --list查看,发现证书renew时间为将近两个月前,但Created的时间为将近4个月前。这说明renew没有成功。
|
||||
|
||||
执行:
|
||||
|
||||
`acme.sh --debug --issue --dns dns_ali -d dev.woyue.org -d *.dev.woyue.org`
|
||||
|
||||
中途报错:
|
||||
|
||||
[Tue Jul 20 11:32:10 CST 2021] GET
|
||||
[Tue Jul 20 11:32:10 CST 2021] url='https://cloudflare-dns.com/dns-query?name=_acme-challenge.dev.woyue.org&type=TXT'
|
||||
[Tue Jul 20 11:32:10 CST 2021] timeout=
|
||||
[Tue Jul 20 11:32:10 CST 2021] _CURL='curl -L --silent --dump-header /root/.acme.sh/http.header -g '
|
||||
[Tue Jul 20 11:32:11 CST 2021] Please refer to https://curl.haxx.se/libcurl/c/libcurl-errors.html for error code: 35
|
||||
[Tue Jul 20 11:32:11 CST 2021] ret='35'
|
||||
|
||||
按上述提示网址查询error code 35:
|
||||
|
||||
**CURLE_SSL_CONNECT_ERROR (35)**
|
||||
|
||||
A problem occurred somewhere in the SSL/TLS handshake. You really want the error buffer and read the message there as it pinpoints the problem slightly more. Could be certificates (file formats, paths, permissions), passwords, and others.
|
||||
|
||||
尝试直接访问对应网址:'https://cloudflare-dns.com/dns-query?name=_acme-challenge.dev.woyue.org&type=TXT',无法访问。
|
||||
|
||||
这是acme.sh内部制定的网址,因此考虑升级acme。
|
||||
|
||||
执行
|
||||
|
||||
`acme.sh --upgrade`
|
||||
|
||||
期间出现提示:
|
||||
|
||||
[Tue Jul 20 11:50:46 CST 2021] acme.sh is using ZeroSSL as default CA now.
|
||||
[Tue Jul 20 11:50:46 CST 2021] Please update your account with an email address first.
|
||||
[Tue Jul 20 11:50:46 CST 2021] acme.sh --register-account -m my@example.com
|
||||
[Tue Jul 20 11:50:46 CST 2021] See: https://github.com/acmesh-official/acme.sh/wiki/ZeroSSL.com-CA
|
||||
[Tue Jul 20 11:50:46 CST 2021] _on_issue_err
|
||||
|
||||
根据提示,需要先注册邮箱:
|
||||
|
||||
[root@ngork certbot]# `acme.sh --register-account -m damnedmoon@163.com`
|
||||
[Tue Jul 20 11:54:05 CST 2021] No EAB credentials found for ZeroSSL, let's get one
|
||||
[Tue Jul 20 11:54:07 CST 2021] Registering account: https://acme.zerossl.com/v2/DV90
|
||||
[Tue Jul 20 11:54:10 CST 2021] Registered
|
||||
[Tue Jul 20 11:54:10 CST 2021] ACCOUNT_THUMBPRINT='8Lcr_kW542VKNC3VCJwbFcuPEaFiunVnzJBxOKJAejM'
|
||||
|
||||
再次执行
|
||||
|
||||
`acme.sh --debug --issue --dns dns_ali -d dev.woyue.org -d *.dev.woyue.org`
|
||||
|
||||
提示成功。执行
|
||||
|
||||
`acme.sh --list`
|
||||
|
||||
Main_Domain KeyLength SAN_Domains CA Created Renew
|
||||
dev.woyue.org "" *.dev.woyue.org ZeroSSL.com Tue Jul 20 03:55:38 UTC 2021 Sat Sep 18 03:55:38 UTC 2021
|
||||
|
||||
可见,证书已经申请成功。
|
||||
|
||||
接下来,重新安装证书并重启nginx docker容器:
|
||||
|
||||
`acme.sh --installcert -d dev.woyue.org -d *.dev.woyue.org \
|
||||
--key-file /srv/certbot/conf/live/dev.woyue.org/privkey.pem \
|
||||
--fullchain-file /srv/certbot/conf/live/dev.woyue.org/fullchain.pem \
|
||||
--reloadcmd "docker restart nginx_nginx_1"`
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<Import_RootNamespace>acme</Import_RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="$(MSBuildThisFileDirectory)实例研究1.md" />
|
||||
<None Include="$(MSBuildThisFileDirectory)README.md" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
117
acme/实例研究1.md
Normal file
117
acme/实例研究1.md
Normal file
@@ -0,0 +1,117 @@
|
||||
## 背景说明
|
||||
|
||||
a. 研究frps服务器的acme部署情况。
|
||||
|
||||
时隔久远,重新确认frps服务器的证书安装途径和现状。
|
||||
|
||||
b. 将gitea部署到现在frps的服务器上。
|
||||
|
||||
## 确认acme的状态
|
||||
|
||||
1. 确认当前证书
|
||||
|
||||
`acme.sh --list`
|
||||
|
||||
[root@ngork ~]# acme.sh --list
|
||||
Main_Domain KeyLength SAN_Domains CA Created Renew
|
||||
dev.woyue.org "" *.dev.woyue.org ZeroSSL.com Sat Sep 18 16:42:15 UTC 2021 Wed Nov 17 16:42:15 UTC 2021
|
||||
|
||||
2. 确认自动更新
|
||||
|
||||
`crontab -e`
|
||||
|
||||
o1 0 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null
|
||||
|
||||
3. 查找acme.sh文件
|
||||
|
||||
`find / -name acme.sh`
|
||||
|
||||
可以定位到当前服务器,这个文件位于:
|
||||
|
||||
/root/.acme.sh/acme.sh
|
||||
|
||||
这里要注意,ls是显示不出来.acme.sh的,可以直接cd .acme.sh
|
||||
|
||||
4. 查看.acme.sh目录下的内容
|
||||
|
||||
[root@ngork .acme.sh]# ls -l
|
||||
total 240
|
||||
-rw-r--r-- 1 root root 315 Sep 19 00:42 account.conf
|
||||
-rwxr-xr-x 1 root root 205958 Jul 20 11:50 acme.sh
|
||||
-rw-r--r-- 1 root root 78 May 17 2020 acme.sh.csh
|
||||
-rw-r--r-- 1 root root 78 May 17 2020 acme.sh.env
|
||||
drwxr-xr-x 4 root root 4096 Jul 20 11:50 ca
|
||||
drwxr-xr-x 2 root root 4096 Jul 20 11:50 deploy
|
||||
drwxr-xr-x 3 root root 4096 May 19 2020 dev.woyue.org
|
||||
drwxr-xr-x 2 root root 4096 Jul 20 11:50 dnsapi
|
||||
-rw-r--r-- 1 root root 252 Oct 27 00:41 http.header
|
||||
drwxr-xr-x 2 root root 4096 Jul 20 11:50 notify
|
||||
|
||||
其中,account.conf中有阿里云的具有DNS操作权限的账户的key和secret。
|
||||
|
||||
## 添加证书
|
||||
|
||||
1. 申请安装证书。加--debug参数可以显示更多细节
|
||||
|
||||
`acme.sh --debug --issue --dns dns_ali -d git.woyue.org`
|
||||
|
||||
2. 安装完毕后,检验是否配置自动任务
|
||||
|
||||
`crontab -e`
|
||||
|
||||
3. 确认当前证书
|
||||
|
||||
`acme.sh --list`
|
||||
|
||||
## 安装证书
|
||||
|
||||
1. 复制证书:
|
||||
|
||||
`mkdir -p /srv/certbot/conf/live/git.woyue.org`
|
||||
|
||||
`acme.sh --installcert -d git.woyue.org \
|
||||
--key-file /srv/certbot/conf/live/git.woyue.org/privkey.pem \
|
||||
--fullchain-file /srv/certbot/conf/live/git.woyue.org/fullchain.pem \
|
||||
--reloadcmd "docker restart nginx_nginx_1"`
|
||||
|
||||
注意,最后的nginx_nginx_1或nginx_server为nginx容器的名称。请根据实际情况修改。**或不加此参数,手动重启nginx**。
|
||||
|
||||
2. 生成:dhparams文件
|
||||
|
||||
`openssl dhparam -out /srv/certbot/conf/ssl-dhparams.pem 2048`
|
||||
|
||||
## 使用证书
|
||||
|
||||
例如,要使用上述证书,则nginx的docker对应etc/letsencrypt的目录就是/srv/certbot/conf。比如说,conf文件里引用的密钥文件路径为:
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/git.woyue.org/fullchain.pem
|
||||
|
||||
那么,docker mount的路径就应该是:-v /srv/certbot/conf:/etc/letsencrypt
|
||||
|
||||
为此,检查一下当前的nginx的volume:
|
||||
|
||||
`docker inspect nginx_nginx_1`
|
||||
|
||||
能看到:
|
||||
|
||||
......
|
||||
|
||||
"Mounts": [
|
||||
......
|
||||
{
|
||||
"Type": "bind",
|
||||
"Source": "/srv/certbot/conf",
|
||||
"Destination": "/etc/letsencrypt",
|
||||
"Mode": "rw",
|
||||
"RW": true,
|
||||
"Propagation": "rprivate"
|
||||
},
|
||||
|
||||
......
|
||||
|
||||
可见,当前的nginx docker实例配置已经满足要求。
|
||||
|
||||
## 后续
|
||||
|
||||
参看Gitea项目的Readme。
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
1. 用acme搞定泛域名ca证书。参看acme项目。
|
||||
2. 部署nginx docker。参看nginx项目。
|
||||
3. 根据nginx docker的网络设置,对应确定自己的docker-compose.yml文件中的对应内容设置正确。其中包括:
|
||||
- nginx所在的网络名称。配置到自己的docker-compose.yml文件中的网络定义中的external->name中去。
|
||||
- nginx所在的网络名称。配置到自己的docker-compose.yml文件中的网络定义中的external->name中去。
|
||||
- 根据网络定义,设定自己的固定ip。
|
||||
- 复制conf.d下的文件到nginx配置目录下的conf.d下。
|
||||
- 确保刚复制的文件配置正确。如其中证书所在路径应符合之前acme复制证书时的目标目录。
|
||||
|
||||
59
frps/README2.md
Normal file
59
frps/README2.md
Normal file
@@ -0,0 +1,59 @@
|
||||
服务器端:
|
||||
centos2:
|
||||
frp已经成功安装在宿主机的/opt/frp目录下,文件权限设置正确。当前的安装情况如下:
|
||||
|
||||
安装路径:
|
||||
|
||||
主目录:/opt/frp
|
||||
可执行文件:frps 和 frpc
|
||||
配置文件:frps.ini, frpc.ini 等
|
||||
|
||||
frps已经成功启动并运行,让我们总结当前的状态:
|
||||
|
||||
服务状态:
|
||||
|
||||
已启用开机自启
|
||||
当前正在运行(PID 5982)
|
||||
使用正确的配置文件(/opt/frp/frps.ini)
|
||||
|
||||
配置文件:
|
||||
[root@izwz90ajic0vbwwzozkri1z frp]# sed -i 's|\$(cat /opt/frp/token)|b01f360897afc5d92125f30e16c1c125|g' /opt/frp/frps.ini && cat /opt/frp/frps.ini
|
||||
|
||||
[common]
|
||||
|
||||
bind_port = 7000
|
||||
|
||||
dashboard_port = 7500
|
||||
|
||||
dashboard_user = hmo
|
||||
|
||||
dashboard_pwd = Git@l2345b7B
|
||||
|
||||
authentication_method = token
|
||||
|
||||
token = b01f360897afc5d92125f30e16c1c125
|
||||
|
||||
allow_ports = 40000-40009
|
||||
|
||||
|
||||
vhost_http_port = 8080
|
||||
|
||||
vhost_https_port = 8443
|
||||
|
||||
客户端(MH-HP):
|
||||
位置:D:\P\Tools3\frp
|
||||
|
||||
目前frpc.toml:
|
||||
serverAddr = "47.106.65.108"
|
||||
serverPort = 7000
|
||||
auth.token = "b01f360897afc5d92125f30e16c1c125"
|
||||
|
||||
[[proxies]]
|
||||
name = "gitea-web"
|
||||
type = "http"
|
||||
localIP = "127.0.0.1"
|
||||
localPort = 3000
|
||||
# remotePort = 6000
|
||||
customDomains = ["git.yoin.fun"]
|
||||
|
||||
目前已经可以通过http://git.yoin.fun:7500/访问dashboard
|
||||
@@ -12,6 +12,7 @@
|
||||
<None Include="$(MSBuildThisFileDirectory)conf.d\frps.conf" />
|
||||
<None Include="$(MSBuildThisFileDirectory)frps\conf\frps.ini" />
|
||||
<None Include="$(MSBuildThisFileDirectory)frps\docker-compose.yml" />
|
||||
<None Include="$(MSBuildThisFileDirectory)README2.md" />
|
||||
<None Include="$(MSBuildThisFileDirectory)README.md" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user