1.准备工具

1台云服务器:随便买个云服务器(可以买按量计费的)
 xshell工具:免费版xshell软件地址https://www.xshell.com/zh/free-for-home-school

2.使用xshell登录云主机后进行隧道配置,打通访问到本地服务

  2.1本地我在idea中的tomcat运行了一个服务,服务端口8080,浏览器访问如下效果

    访问地址:http://localhost:8080/hello

    

2.2 xshell配置隧道

2.3 验证隧道转发效果

curl http://localhost:8084/hello

2.4使用云服务器的公网ip访问进行转发,需要借助nginx,操作如下

2.4.1执行 yum install nginx -y

2.4.2执行命令find / -name nginx.conf 找到nginx.config 配置文件

 2.4.3修改配置文件vi /etc/nginx/nginx.conf

       增加如下配置:
        proxy_pass http://localhost:8084;

2.4.4启动服务执行命令 nginx

 2.5最终效果

  2.5.1 直接公网ip加nginx的80端口访问

    

2.5.2 在idea运行的项目接口上打断点效果


Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐