首页 > 编程知识 正文

nps内网穿透教程,nps 内网穿透

时间:2023-05-05 02:34:39 阅读:197711 作者:3569

nps实现代理,实现http请求代理到内网http端口

nps是一款轻量级、高性能、功能强大的内网代理服务器。目前支持tcp、udp流量转发,可支持任何tcp、udp上层协议(访问内网网站、本地支付接口调试、ssh访问、远程桌面,内网dns解析等等……),此外还支持内网http代理、内网socks5代理、p2p等,并带有功能强大的web管理端。

背景:

做微信公众号开发、小程序开发等----> 域名代理模式想在外网通过ssh连接内网的机器,做云服务器到内网服务器端口的映射,----> tcp代理模式在非内网环境下使用内网dns,或者需要通过udp访问内网机器等----> udp代理模式在外网使用HTTP代理访问内网站点----> http代理模式搭建一个内网穿透ss,在外网如同使用内网vpn一样访问内网资源或者设备----> socks5代理模式

相关地址:
nps github地址:
https://github.com/cnlh/nps

CentOS服务器端安装包:https://github.com/cnlh/nps/releases/download/v0.23.2/linux_arm64_server.tar.gz

Windows客户端安装包:
https://github.com/cnlh/nps/releases/download/v0.23.2/win_amd64_client.tar.gz

在CentOS服务器上安装nps server 直接解压linux_arm64_server.tar.gz tar -zxvf linux_arm64_server.tar.gz 修改nps.conf appname = nps#Boot mode(dev|pro)runmode = pro#HTTP(S) proxy port, no startup if emptyhttp_proxy_ip=0.0.0.0http_proxy_port=8088#https_proxy_port=443#https_just_proxy=true#default https certificate setting#https_default_cert_file=conf/server.pem#https_default_key_file=conf/server.key##bridgebridge_type=tcpbridge_port=8024bridge_ip=0.0.0.0 启动nps server ./nps start 访问nps server管理界面

http://localhost:8080

现在有个需求访问http://api.example.com代理到内网http://127.0.0.1:8080端口

主要流程如下:
http://api.example.com -> nps server -> http://127.0.0.1:8080

http://api.example 通过nginx代理到nps server的8088端口

配置如下:
default.conf

server { listen 80; listen 443 ssl; server_name api.example.com; include /etc/nginx/common/example.com.ssl.conf; location / { proxy_pass http://localhost:8088; } if ($scheme != 'https') { rewrite ^(.*)$ https://$server_name$1 permanent; }}

example.com.ssl.conf

ssl_certificate cert/example.com/fullchain.cer;ssl_certificate_key cert/example.com/example.com.key;ssl_session_timeout 5m;ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_prefer_server_ciphers on; 在nps server web管理后台创建客户端


在Windows上安装nps client

直接解压win_amd64_client.tar.gz

配置npc.conf

[common]server_addr=[nps server服务器IP]:8024conn_type=tcpvkey=[客户端vkey]auto_reconnection=truemax_conn=1000flow_limit=1000rate_limit=1000basic_username=11basic_password=3web_username=userweb_password=1234crypt=truecompress=true

启动客户端
nps -config=conf/npc.conf

启动成功后可以看到client list id为2的client状态变为online的状态

配置域名解析


配置成功后,访问http://api.example.com 会被代理到内网的http://localhost:8080端口

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。