200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > Cpolar实现虚拟机内网穿透 搭建私人云服务器

Cpolar实现虚拟机内网穿透 搭建私人云服务器

时间:2021-07-10 17:06:56

相关推荐

Cpolar实现虚拟机内网穿透 搭建私人云服务器

Cpolar实现虚拟机内网穿透,搭建私人云服务器

一、Cpolar功能介绍

Cpolar官网

Cpolar是一个安全的内网穿透的服务,可以将内网下的本地服务器通过安全隧道暴漏给公网。允许公网用户可以正常访问内网服务,是一款免费的内网穿透软件。只需要一行命令,就可以将内网站点发布到公网,方便使用。

1 Cpolar是怎么工作?

1.1 下载Cpolar

在你机器上下载并允许Cpolar客户端,并为其提供一个本地的网络服务的端口号,通常是你本地的Web服务器端口号,例如8080端口。终端输入:cpolar http 8080

1.2 连接你的服务

连接到接受公共地址流量的cpolar云服务

1.3 从任何地方

流量被中继到你的机器运行的cpolar进程,然后再中继到你指定的本地服务器端口(本地中为8080端口)

2 Cpolar能用在哪些场景?

微信公众号开发,实时断电调试微信消息在没有上线部署的情况下,在发布会上演示新网站在你的开发机器上构建webhook客户程序,聊天机器人无需部署,测试连接到本地开发环境后端的移动应用程序为已经在生产环境部署的设备,提供稳定的公网访问地址从你家中运行个人云服务、AI深度学习、聊天机器人远程控制家中的电脑

2.1 公开本地网站

启用本地Web网站后,cpolar通过将其指向运行本地服务器的端口来启动:cpolar http 80。输出将列出URL,该URL将指向你的本地服务器。还可以在状态页上看到列出的所有活动隧道。

2.2 微信公众号开发测试

当本地服务器未连接到Web时,调试API集成始终具有挑战性,cpolar可以解决这一点。启动cpoar并将隧道的URL粘贴到微信公号对接服务器的URL字段中。入站请求将转发到本地开发环境。确保尝试使用cpolar监听器(http://localhost:4040)查看请求日志。处理一个讨厌的bug? 甚至可以重播请求消息包,加速测试的请求,而不是手动重新触发操作。

2.3 在移动设备上测试

大量的程程序员和设计师依靠cpolar在他们移动设备上快速测试网站和应用程序。首先,启动cpolar以获取本地服务器的URL:cpolar http <your_server_port>。接下来,获取转发网址,cpolar返回并将其加载到手机,以便立即访问你的应用。

2.4 远程控制树莓派

如果你发现自己使用Raspbeery Pi或者任何类似的网络连接设备,那么快速轻松进行远程访问非常有用。首先,确保在设备上安装cpolar。接下来,通过侦听你选择的任何端口在设备上启动TCP隧道:cpolar tcp 22

3 Cpolar一些很棒的功能

4 Cpolar高级套餐

二、Cpolar官网注册

1 账号注册

自行创建账号,后续安装cpolar需要用到

2 套餐选择

根据需求选择套餐,这里选择免费套餐

3 获取隧道Authtoken

在验证栏里可以获取你账号对应的Authtoken,你必须为cpolar指定authtoken,以便客户端与此账户绑定。cpolar将你的authtoken保存在~/.cpolar/cpolar.yml中,这样你就不需要重复这一步了。

三、Cpolar安装

准备虚拟机一台:192.168.130.100

1 方法一:官网直接下载安装

账号登录后,可以直接在首页查看如下,可以直接下载安装包,解压使用。如果选择这种方式安装,可以按照如下步骤进行。

2 方法二:curl下载安装

2.1 curl下载

curl -L /static/downloads/install-release-cpolar.sh | sudo bash

[root@hadoop ~]# curl -L /static/downloads/install-release-cpolar.sh | sudo bash% Total % Received % Xferd Average Speed Time TimeTime CurrentDload Upload Total Spent Left Speed100 21836 100 21836 00 516970 --:--:-- --:--:-- --:--:-- 51866info: Installing Cpolar 3.2.88.16 for x86_64Downloading Cpolar archive: /downloads/releases/3.2.88.16/cpolar-stable-linux-amd64.zip....

2.2 检查Cpolar是否安装成功

[root@hadoop ~]# cpolar versioncpolar version 3.2.88.16

2.3 token认证

这里需要使用的就是,在官网注册章节获取的隧道Authtoken

cpolar authtoken xxxxxxxxxxxxxxxx

[root@hadoop ~]# cpolar authtoken AAAAAAAAAAAAAAAAuthtoken saved to configuration file: /usr/local/etc/cpolar/cpolar.yml

2.4 启动cpolar

启动cpolar进程

systemctl start cpolar

查看cpolar进程状态

systemctl status cpolar

关闭cpolar进程

systemctl stop cpolar

[root@hadoop ~]# systemctl start cpolar[root@hadoop ~]# systemctl status cpolar● cpolar.service - Cpolar ServiceLoaded: loaded (/etc/systemd/system/cpolar.service; disabled; vendor preset: disabled)Active: active (running) since 六 -12-10 19:21:06 CST; 2s agoDocs: /docsMain PID: 88783 (cpolar)Tasks: 13Memory: 21.8MCGroup: /system.slice/cpolar.service├─88783 cpolar: master process└─88789 cpolar: worker process12月 10 19:21:06 hadoop systemd[1]: Started Cpolar Service.

2.5 设置开机自启

systemctl enable cpolar

[root@hadoop ~]# systemctl enable cpolarCreated symlink from /etc/systemd/system/multi-user.target.wants/cpolar.service to /etc/systemd/system/cpolar.service.[root@hadoop ~]#

2.6 关闭防火墙

关闭防火墙

systemctl stop firewalld

查看防火墙状态

systemctl status firewalld

开启防火墙

systemctl start firewalld

[root@hadoop ~]# systemctl stop firewalld[root@hadoop ~]# systemctl status firewalld● firewalld.service - firewalld - dynamic firewall daemonLoaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)Active: inactive (dead)Docs: man:firewalld(1)

四、Cpolar配置

1 Cpolar登录

安装好cpolar后,默认都是9200端口,登录的账号密码是你在Cpolar官网注册的账号使用的账号密码。账号一般是注册时使用的邮箱。

http://192.168.130.100:9200

2 Cpolar隧道列表

Cpolar安装完成,默认会存在两个样例隧道:

一个是ssh隧道,指向22端口,tcp协议一个是Website隧道,指向8080端口,http协议

后续如果需要可以再创建新的隧道

五、隧道功能测试

在线隧道列表中,有如下三条数据

第一条是ssh隧道,协议是tcp,将本地地址转发到公网地址,默认是将本地的22端口转发到了23337端口

第二条是website隧道,协议是http协议,默认是将8080端口转发到对应公网地址的80端口

第三条是website隧道,协议是https协议,默认是将8080端口转发到对应公网地址的80端口

1 ssh隧道功能测试

使用在线隧道列表中,使用ssh隧道的公网地址,远程登录本地服务器

登录成功

2 website隧道功能测试

服务器中尚未部署web项目,所以使用打算在虚拟机中部署一个静态HTML页面来测试效果。

参考:HTML静态页面配置到服务器

2.1 安装httpd

[root@hadoop ~]# yum install httpd已加载插件:fastestmirrorLoading mirror speeds from cached hostfile* base: ftp.* epel: mirrors.tuna.* extras: * updates: 正在解决依赖关系--> 正在检查事务

2.2 启动httpd

[root@hadoop ~]# systemctl enable httpd.serviceCreated symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.[root@hadoop ~]# systemctl is-enabled httpd.serviceenabled[root@hadoop ~]# systemctl start httpd.service[root@hadoop ~]# systemctl status httpd.service● httpd.service - The Apache HTTP ServerLoaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)Active: active (running) since 六 -12-10 20:16:34 CST; 7s agoDocs: man:httpd(8)man:apachectl(8)Main PID: 117684 (httpd)Status: "Processing requests..."Tasks: 6Memory: 2.8MCGroup: /system.slice/httpd.service

2.3 修改端口

[root@hadoop ~]# vim /etc/httpd/conf/httpd.conf

2.4 部署html页面

# 打开html目录[root@hadoop ~]# cd /var/www/html/## 写html代码[root@hadoop html]# vim index.html.....## 重启http服务[root@hadoop html]# systemctl restart httpd.service

2.5 远程公网地址访问成功

http://385f408e./

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。