Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b56e52d

Browse files
committed
m
1 parent 773cad9 commit b56e52d

File tree

8 files changed

+237
-21
lines changed

8 files changed

+237
-21
lines changed

04k8s(10.1.12.20-29)/09consul/00pull.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
# qq group:573283836
44

5-
65
docker pull consul:0.9.1
76
docker tag consul:0.9.1 10.1.12.61:5000/consul:0.9.1
87
docker push 10.1.12.61:5000/consul:0.9.1

05k8s(192.168.0.20)/02nginxproxy/00readme.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
1、在192.168.0.20 建立nginx代理
66

77

8-
98
2、每台机器加上http-proxy的指向
109

1110

12-
1311
3、yum 用不了,需要把yum源换成aliyun的http,同时把其中file协议换成http
1412

1513

05k8s(192.168.0.20)/02nginxproxy/98proxycp.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ for ip in $NODE_IPS ;do
3131
echo "初始化$ip proxy..."
3232
Script="
3333
echo \" export http_proxy=http://192.168.0.20:85 \" >> /etc/profile
34-
echo \" export https_proxy=https://192.168.0.20:443 \" >> /etc/profile
34+
#echo \" export https_proxy=https://192.168.0.20:443 \" >> /etc/profile
3535
source /etc/profile
3636
curl www.google.cn
3737
"
@@ -40,5 +40,7 @@ for ip in $NODE_IPS ;do
4040
done
4141

4242

43+
44+
4345
# echo " export http_proxy=http://192.168.0.20:85 " >> /etc/profile
4446
# source /etc/profile

05k8s(192.168.0.20)/02nginxproxy/CentOS-Base.repo

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
1717
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
1818
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
1919
gpgcheck=1
20+
#gpgkey=file:///mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
2021
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
2122

2223
#released updates
@@ -27,6 +28,7 @@ baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
2728
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
2829
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
2930
gpgcheck=1
31+
#gpgkey=file:///mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
3032
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
3133

3234
#additional packages that may be useful
@@ -37,6 +39,8 @@ baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
3739
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
3840
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
3941
gpgcheck=1
42+
#
43+
#gpgkey=file:///mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
4044
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
4145

4246
#additional packages that extend functionality of existing packages
@@ -48,6 +52,7 @@ baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
4852
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
4953
gpgcheck=1
5054
enabled=0
55+
#gpgkey=file:///mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
5156
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
5257

5358
#contrib - packages by Centos Users

05k8s(192.168.0.20)/02nginxproxy/epel.repo

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ baseurl=http://mirrors.aliyun.com/epel/7/$basearch
66
failovermethod=priority
77
enabled=1
88
gpgcheck=0
9-
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
9+
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
10+
gpgkey=http://etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
1011

1112
[epel-debuginfo]
1213
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug

05k8s(192.168.0.20)/02nginxproxy/nginx.conf

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ worker_processes 1;
22
master_process off;
33
#daemon off;
44
#pid /var/run/nginx.pid;
5-
65
events {
7-
worker_connections 768;
6+
worker_connections 768;
87
# multi_accept on;
98
}
109

@@ -21,23 +20,14 @@ http {
2120

2221
sendfile on;
2322
server {
23+
#域名服务器
2424
resolver 202.120.2.100;
25+
#监听本机端口,其它机器都指向本机的ip该端口上进行代理
2526
listen 85;
2627
location / {
2728
#proxy_pass http://$http_host$request_uri;
28-
proxy_pass $scheme://$http_host$request_uri;
29-
#proxy_pass http://mirrors.aliyun.com/epel/;
30-
}
31-
location /epel/ {
32-
proxy_pass http://mirrors.aliyun.com/epel/ ;
33-
}
34-
location /ubuntu/ {
35-
proxy_pass http://mirrors.aliyun.com/ubuntu/ ;
36-
}
37-
38-
location /centos/ {
39-
proxy_pass http://mirrors.aliyun.com/centos/ ;
40-
}
29+
proxy_pass $scheme://$http_host$request_uri;
30+
}
4131
}
4232

4333
}

doc/06springboot-docker-ssl-init.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,137 @@ done
213213
214214
```
215215

216+
217+
## yum源的问题
218+
219+
采用阿里的CentOS-Base.repo,这里需要编辑其gpgkey的地址,它原来是file协议,反向代理不了。修改成http即可
220+
### 创建/aliyunRepo/CentOS-Base.repo文件
221+
222+
```
223+
# CentOS-Base.repo
224+
#
225+
# The mirror system uses the connecting IP address of the client and the
226+
# update status of each mirror to pick mirrors that are updated to and
227+
# geographically close to the client. You should use this for CentOS updates
228+
# unless you are manually picking other mirrors.
229+
#
230+
# If the mirrorlist= does not work for you, as a fall back you can try the
231+
# remarked out baseurl= line instead.
232+
#
233+
#
234+
235+
[base]
236+
name=CentOS-$releasever - Base - mirrors.aliyun.com
237+
failovermethod=priority
238+
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
239+
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
240+
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
241+
gpgcheck=1
242+
#gpgkey=file:///mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
243+
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
244+
245+
#released updates
246+
[updates]
247+
name=CentOS-$releasever - Updates - mirrors.aliyun.com
248+
failovermethod=priority
249+
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
250+
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
251+
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
252+
gpgcheck=1
253+
#gpgkey=file:///mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
254+
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
255+
256+
#additional packages that may be useful
257+
[extras]
258+
name=CentOS-$releasever - Extras - mirrors.aliyun.com
259+
failovermethod=priority
260+
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
261+
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
262+
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
263+
gpgcheck=1
264+
#
265+
#gpgkey=file:///mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
266+
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
267+
268+
#additional packages that extend functionality of existing packages
269+
[centosplus]
270+
name=CentOS-$releasever - Plus - mirrors.aliyun.com
271+
failovermethod=priority
272+
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
273+
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
274+
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
275+
gpgcheck=1
276+
enabled=0
277+
#gpgkey=file:///mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
278+
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
279+
280+
#contrib - packages by Centos Users
281+
[contrib]
282+
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
283+
failovermethod=priority
284+
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
285+
http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
286+
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
287+
gpgcheck=1
288+
enabled=0
289+
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
290+
291+
292+
293+
```
294+
295+
### 创建/aliyunRepo/epel.repo文件
296+
297+
```
298+
[epel]
299+
name=Extra Packages for Enterprise Linux 7 - $basearch
300+
baseurl=http://mirrors.aliyun.com/epel/7/$basearch
301+
http://mirrors.aliyuncs.com/epel/7/$basearch
302+
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
303+
failovermethod=priority
304+
enabled=1
305+
gpgcheck=0
306+
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
307+
gpgkey=http://etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
308+
309+
[epel-debuginfo]
310+
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
311+
baseurl=http://mirrors.aliyun.com/epel/7/$basearch/debug
312+
http://mirrors.aliyuncs.com/epel/7/$basearch/debug
313+
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
314+
failovermethod=priority
315+
enabled=0
316+
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
317+
gpgcheck=0
318+
319+
[epel-source]
320+
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
321+
baseurl=http://mirrors.aliyun.com/epel/7/SRPMS
322+
http://mirrors.aliyuncs.com/epel/7/SRPMS
323+
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
324+
failovermethod=priority
325+
enabled=0
326+
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
327+
gpgcheck=0
328+
329+
330+
```
331+
332+
### 分发到每台机器上
333+
NODE_IPS="192.168.0.2 192.168.0.5 192.168.0.6 192.168.0.7 192.168.0.8 192.168.0.9 192.168.0.10 192.168.0.11 192.168.0.12 192.168.0.13 192.168.0.14 192.168.0.15 192.168.0.16 192.168.0.17 192.168.0.18 192.168.0.19"
334+
NODE_NAME="ms02 ms05 ms06 ms07 ms08 ms09 ms10 ms11 ms12 ms13 ms14 ms15 ms16 ms17 ms18 ms19"
335+
336+
for ip in $NODE_IPS ;do
337+
echo "初始化$ip aliyu 的..."
338+
ssh root@$ip "cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak1"
339+
ssh root@$ip "cp /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.bak1"
340+
341+
scp /aliyunRepo/CentOS-Base.repo root@$ip:/etc/yum.repos.d/CentOS-Base.repo
342+
scp /aliyunRepo/epel.repo root@$ip:/etc/yum.repos.d/epel.repo
343+
344+
ssh root@$ip " ls /etc/yum.repos.d/"
345+
346+
sleep 10
347+
done
348+
349+
```
Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,88 @@
1-
# Spring boot+docker 半自动化部署(七)、反向代理上网
1+
# Spring boot+docker 半自动化部署(七)、反向代理上网
2+
3+
网络安全要求较高,只有192.168.0.20能上外网,其它机器都上不了网,只能使用反向代理上网,建立反向代理:
4+
1、在192.168.0.20 建立nginx代理
5+
2、每台机器加上http-proxy的指向
6+
3、yum 用不了,需要把yum源换成aliyun的http,同时把其中file协议换成http
7+
8+
## nginx的配置文件
9+
nginx的docker部署非常方便,和前面文件服务器一样,只要拉镜像运行即可,其关键在于配置文件
10+
默认的情况下,nginx没有配置文件,需要在/etc/nginx/nginx.conf位置配置主配置文件,没有主配置文件,直接配置子配置文件在docker中会报错“找不到/etc/nginx/nginx.conf文件”
11+
这里仅仅做反向代理用,就直接配置在主配置文件中即可
12+
13+
在管理机主机创建/etc/nginx/nginx.conf中,然后把该文件映射到docker中,这样就不需要在docker容器中配置
14+
15+
```
16+
worker_processes 1;
17+
master_process off;
18+
#daemon off;
19+
#pid /var/run/nginx.pid;
20+
events {
21+
worker_connections 768;
22+
# multi_accept on;
23+
}
24+
25+
http {
26+
#include mime.types;
27+
default_type application/octet-stream;
28+
29+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
30+
'$status $body_bytes_sent "$http_referer" '
31+
'"$http_user_agent" "$http_x_forwarded_for"';
32+
33+
#access_log /var/log/nginx/access.log;
34+
#error_log /var/log/nginx/error.log;
35+
36+
sendfile on;
37+
server {
38+
#域名服务器
39+
resolver 202.120.2.100;
40+
#监听本机端口,其它机器都指向本机的ip该端口上进行代理
41+
listen 85;
42+
location / {
43+
#proxy_pass http://$http_host$request_uri;
44+
proxy_pass $scheme://$http_host$request_uri;
45+
}
46+
}
47+
}
48+
49+
```
50+
51+
52+
## nginx的启动
53+
54+
启用反向代理的docker比较简单,拉镜像下载启动
55+
56+
```
57+
docker run -d -v /etc/nginx:/etc/nginx -v /usr/local/nginx/conf/:/usr/local/nginx/conf/ --restart=always \
58+
--privileged=true --net=host --name nginx-proxy -p 85:85 nginx
59+
60+
```
61+
62+
这里关键是把其位置和本地位置进行映射即可,其配置文件配置的端口也需要在主机上映射出来。
63+
如果不行,那么就docker restart nginx-proxy,重启一下。
64+
65+
## 每台机器指向该端口
66+
67+
在代理机只需要编写http_proxy环境变量,把该变量指指定管理机即可
68+
下面采用批量的形式把http_proxy写入/etc/profile
69+
70+
```
71+
NODE_IPS="192.168.0.2 192.168.0.5 192.168.0.6 192.168.0.7 192.168.0.8 192.168.0.9 192.168.0.10 192.168.0.11 192.168.0.12 192.168.0.13 192.168.0.14 192.168.0.15 192.168.0.16 192.168.0.17 192.168.0.18 192.168.0.19"
72+
NODE_NAME="ms02 ms05 ms06 ms07 ms08 ms09 ms10 ms11 ms12 ms13 ms14 ms15 ms16 ms17 ms18 ms19"
73+
74+
for ip in $NODE_IPS ;do
75+
echo "初始化$ip proxy..."
76+
Script="
77+
echo \" export http_proxy=http://192.168.0.20:85 \" >> /etc/profile
78+
#echo \" export https_proxy=https://192.168.0.20:443 \" >> /etc/profile
79+
source /etc/profile
80+
curl www.google.cn
81+
"
82+
ssh root@$ip "$Script"
83+
sleep 5
84+
done
85+
86+
```
87+
88+

0 commit comments

Comments
 (0)