我是靠谱客的博主 文静绿草,这篇文章主要介绍Docker 安装运行 Rancher(并配置HTTPS) 配置域名访问,现在分享给大家,希望可以做个参考。

在服务器使用docker 启动 ranhcer 

复制代码
1
docker run -d --restart=unless-stopped --name=rancher -p 8001:80 -p 8002:443 rancher/rancher

我的服务器ip是 115.159.52.223:8002

启动之后能够使用 https://115.159.52.223:8002/ 访问到rancher服务

 

下面是nginx的配置

代理 文件 监听80端口 如果来访的域名是  rancher.mczaiyun.top 则将根目录代理到

https://115.159.52.223:8002

注意末尾没有  /

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
map $http_upgrade $connection_upgrade { default Upgrade; '' close; } server { listen 443 ssl; server_name rancher.mczaiyun.top; ssl_certificate /etc/nginx/cert/rancher.mczaiyun.top.pem; ssl_certificate_key /etc/nginx/cert/rancher.mczaiyun.top.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; add_header Access-Control-Allow-Origin *; location / { proxy_pass https://115.159.52.223:8002; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Port $server_port; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_read_timeout 900s; } }

 

如果要用上面这段配置 你只需要改以下四处就行了

你的域名,你的SSL证书  你要代理的真正的地址

复制代码
1
2
3
4
5
6
server_name rancher.mczaiyun.top; ssl_certificate /etc/nginx/cert/rancher.mczaiyun.top.pem; ssl_certificate_key /etc/nginx/cert/rancher.mczaiyun.top.key;  proxy_pass https://115.159.52.223:8002; 

 

 

下面这段代码是代理socket的服务

复制代码
1
2
3
4
5
6
7
8
9
map $http_upgrade $connection_upgrade { default Upgrade; '' close; } ...... proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade;

 

欢迎访问我的ranhcer 服务

https://rancher.mczaiyun.top

最后

以上就是文静绿草最近收集整理的关于Docker 安装运行 Rancher(并配置HTTPS) 配置域名访问的全部内容,更多相关Docker内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(95)

评论列表共有 0 条评论

立即
投稿
返回
顶部