Wong's Blog

Always on the way forward
  1. 首页
  2. Linux
  3. 正文

内网穿透代理NPS和NGINX的和谐共处

2024 年 7 月 17 日 1026点热度 54条评论

NPS是一款轻量级、高性能、功能强大的内网穿透代理服务器,几乎支持所有协议,支持内网http代理、内网socks5代理、p2p等,简洁但功能强大的WEB管理界面,支持服务端、客户端同时控制,扩展功能强大,全平台兼容.

  • 官方网址 https://github.com/ehang-io/nps

但是NGINX已经占用了443端口,以下方法可以让NPS和NGINX都能用到443端口.

  • 每次修改完nginx.conf和npss.conf文件都要重启nginx,命令:systemctl restart nginx
  • 每次修改完nps.conf文件都要重启nps,命令:nps restart

1. 安装NPS

#创建nps工作目录并进入
mkdir  /home/nps
cd /home/nps
#下载服务端程序
wget https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_server.tar.gz
#解压
tar -xf linux_amd64_server.tar.gz
#安装
./nps install

2. 配置nps.conf文件

**
**
#HTTP(S) proxy port, no startup if empty
http_proxy_ip=0.0.0.0
http_proxy_port=7780  /*为了不和nginx的80端口冲突,此处修改为7780端口*/
#https_proxy_port=7443
#https_just_proxy=true
#default https certificate setting
#https_default_cert_file=conf/server.pem
#https_default_key_file=conf/server.key
**
**
# if web under proxy use sub path. like http://host/nps need this.
web_base_url=/nps      /*配合nginx的location*/
**
**

3. nginx配置文件

server {
        listen 443 ssl;
        
        server_name aa.bb.com;
        ssl_certificate       /home/cert/**.pem;
        ssl_certificate_key   /home/cert/**.key;
        **
        **
        location /nps {
            proxy_redirect off;
            proxy_pass http://127.0.0.1:8080;   /*访问http://ip/nps,会跳转到127.0.0.1:8080(web界面)*/
            proxy_http_version 1.1;
            proxy_set_header Host $host;
        }
       **
       **
       include /etc/nps/conf/npss.conf;    /*另外添加一个nps的配置*/    
       }

4. 至此,nps的web界面已经可以打开,打开网址为第三步的https://aa.bb.com/nps,在web界面新建客户端.

备注:可留空
认证用户名:可留空
认证密码:可留空
验证密钥: 系统随机
允许***,压缩,加密:是

生成客户端后,点击客户端前面的+号,有客户端命令,在内网的客户端用此命令启动nps_client.稍等一会,客户端界面会显示此客户端已经在线.至此,客户端和服务器端连接成功.

5. 访问内网的web服务器.

①.修改npss.conf配置文件

server {
 listen 80;
 server_name openwrt.bb.com;
 return 301 https://$host$request_uri;
}
server {
 listen 443 ssl http2;
 server_name openwrt.bb.com;
 ssl_certificate /home/cert/**.pem;
 ssl_certificate_key /home/cert/**.key;
 location / {
 proxy_pass http://127.0.0.1:7780;     /*nginx的流量转到7780端口(nps的代理端口)
 proxy_redirect http://$host/ http://$http_host/;
 proxy_set_header X-Real-IP $remote_addr;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_set_header Host $host;
}
}

②.在NPS的web界面添加域名解析.

新增域名解析:
客户端ID:第四部创建客户端后,系统会分配一个ID
主机:openwrt.bb.com   /*和第五步的①中的server_name对应*/
模式:http
目标:IP:端口    /*内网web服务器的IP及访问端口*/

6. 现在可用https://openwrt.bb.com访问内网web服务器.

网络流程图:

标签: 暂无
最后更新:2024 年 7 月 18 日

wong

这个人很懒,什么都没留下

点赞
< 上一篇

文章评论

  • finasteride and minoxadil hair regrowth

    <a href=https://propecia2buy.top/>propecia results</a> J Am Coll Cardiol Img 6 1141 1151

    2025 年 3 月 10 日
    回复
  • zoritoler imol

    I like this weblog very much, Its a real nice position to read and receive info .

    2025 年 3 月 11 日
    回复
  • vorbelutrioperbir

    Hi my loved one! I wish to say that this post is awesome, great written and come with almost all important infos. I¦d like to look extra posts like this .

    2025 年 3 月 31 日
    回复
  • droversointeru

    There's noticeably a bundle to know about this. I assume you made sure nice factors in options also.

    2025 年 4 月 2 日
    回复
  • Robt Muscaro

    Saved as a favorite, I really like your blog!

    2025 年 6 月 30 日
    回复
  • best THC edibles

    Good shout<a href="https://www.morningstar.com/news/globe-newswire/9489727/area-52-named-1-best-thc-gummies-by-oregon-observer"&gt;.</a>

    2025 年 7 月 9 日
    回复
  • ace ultra premium weed pen

    Nice

    2025 年 7 月 11 日
    回复
  • thca gummies

    thca gummies area 52

    2025 年 7 月 11 日
    回复
  • weed pen

    <a href="https://www.morningstar.com/news/globe-newswire/9493483/disposable-weed-pen-premium-award-winning-all-in-one-thc-vaporizers-launched-by-area-52>Area 52 has the best disposable weed pen according to Morningstar consumer reviews</a>

    2025 年 7 月 14 日
    回复
  • Anxiety

    <a href="https://xx.area52.me/go/cbd1.php>Anxiety</a&gt;

    2025 年 7 月 15 日
    回复
  • where to buy thca

    where to buy thca area 52

    2025 年 7 月 17 日
    回复
  • best sativa thc carts

    best sativa thc carts area 52

    2025 年 7 月 17 日
    回复
  • full spectrum cbd gummies

    full spectrum cbd gummies area 52

    2025 年 7 月 17 日
    回复
  • thc gummies

    thc gummies

    2025 年 7 月 17 日
    回复
  • thc gummies for sleep

    thc gummies for sleep area 52

    2025 年 7 月 17 日
    回复
  • best sativa thc edibles

    best sativa thc edibles area 52

    2025 年 7 月 17 日
    回复
  • distillate carts

    distillate carts area 52

    2025 年 7 月 17 日
    回复
  • buy pre rolls online

    buy pre rolls online area 52

    2025 年 7 月 17 日
    回复
  • infused pre rolls

    infused pre rolls area 52

    2025 年 7 月 17 日
    回复
  • thca diamonds

    thca diamonds area 52

    2025 年 7 月 17 日
    回复
  • live rosin gummies

    live rosin gummies area 52

    2025 年 7 月 17 日
    回复
  • live resin gummies

    live resin gummies area 52

    2025 年 7 月 17 日
    回复
  • best indica thc weed pens

    best indica thc weed pens area 52

    2025 年 7 月 17 日
    回复
  • thc gummies for anxiety

    thc gummies for anxiety area 52

    2025 年 7 月 17 日
    回复
  • thc oil

    thc oil area 52

    2025 年 7 月 17 日
    回复
  • thc tincture

    thc tincture area 52

    2025 年 7 月 17 日
    回复
  • disposable weed pen

    disposable weed pen area 52

    2025 年 7 月 17 日
    回复
  • thc pen

    thc pen area 52

    2025 年 7 月 17 日
    回复
  • thca flower

    thca flower area 52

    2025 年 7 月 17 日
    回复
  • live resin

    live resin area 52

    2025 年 7 月 17 日
    回复
  • thc microdose gummies

    thc microdose gummies area 52

    2025 年 7 月 17 日
    回复
  • mood gummies

    mood gummies area 52

    2025 年 7 月 17 日
    回复
  • thca vape

    thca vape area 52

    2025 年 7 月 17 日
    回复
  • liquid diamonds

    liquid diamonds area 52

    2025 年 7 月 17 日
    回复
  • thc vape hybrid

    thc vape hybrid area 52

    2025 年 7 月 17 日
    回复
  • liquid thc

    liquid thc area 52

    2025 年 7 月 17 日
    回复
  • legal mushroom gummies

    legal mushroom gummies area 52

    2025 年 7 月 17 日
    回复
  • snow caps thca

    snow caps thca area 52

    2025 年 7 月 17 日
    回复
  • thc gummies for pain

    thc gummies for pain area 52

    2025 年 7 月 17 日
    回复
  • live resin carts

    live resin carts area 52

    2025 年 7 月 17 日
    回复
  • thcv gummies

    thcv gummies area 52

    2025 年 7 月 17 日
    回复
  • hybrid gummies

    hybrid gummies area 52

    2025 年 7 月 17 日
    回复
  • indica gummies

    indica gummies area 52

    2025 年 7 月 17 日
    回复
  • CBD Gummies 2025: Best CBD Gummies for Pain Anxiety & Sleep

    <a href="https://irb.harvard.edu/Shibboleth.sso/Logout?return=https://royalcbd.com/cbd-gummies/>CBD Gummies 2025: Best CBD Gummies for Pain Anxiety & Sleep</a>

    2025 年 7 月 18 日
    回复
  • Florrie Slater

    Hello there from DreamProxies.com

    Amazing news: top quality, fast speed and reliable private proxies now even cheaper:
    50% OFF - For All Private Proxies!

    View proxy offers and sales:

    http://tiny.cc/DreamProxies-Discounts

    Key features and advantages that come with all proxies plan on DreamProxies:
    + Complete Anonymity - fully private and anonymous quality proxy servers
    + Ultimate Quality - highest superior quality and reliability with each proxy package
    + Blazing Speed - up to 1,000 mb/s per proxy - fastest speed servers
    + Unlimited Data - no usage limits and absolute freedom using proxies
    + Reliable Servers - fully-powered stable datacenter proxy servers
    + Low Prices - among the cheapest proxy services you can find on the market
    + Extra Discounts - exclusive promo codes and sales for proxies on website

    50% SALE for all proxies plans - by DreamProxies.com

    2025 年 8 月 12 日
    回复
  • olxtoto

    Nice post. I learn one thing tougher on completely different blogs everyday. It will at all times be stimulating to learn content material from different writers and practice a bit of one thing from their store. I’d favor to use some with the content material on my blog whether you don’t mind. Natually I’ll provide you with a hyperlink on your web blog. Thanks for sharing.

    2025 年 8 月 18 日
    回复
  • naomi campbell

    Hey there! I've been reading your blog for some time now and finally got
    the courage to go ahead and give yoou a shout out from Kingwood Tx!
    Just wanted to tell you keep up the good work!

    2025 年 8 月 21 日
    回复
  • idn poker

    Can I just say what a relief to find someone who actually knows what theyre talking about on the internet. You definitely know how to bring an issue to light and make it important. More people need to read this and understand this side of the story. I cant believe youre not more popular because you definitely have the gift.

    2025 年 8 月 22 日
    回复
  • tlovertonet

    I am no longer certain where you are getting your info, however good topic. I must spend a while studying more or figuring out more. Thanks for excellent information I used to be in search of this information for my mission.

    2025 年 8 月 24 日
    回复
  • Delta 3 THC Delta 6a10a THC

    Hi, I think your website might be having browser compatibility issues. When I look at your website in Safari, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, fantastic blog!

    2025 年 8 月 25 日
    回复
  • real estate uruguay

    Nice read, I just passed this onto a friend who was doing a little research on that. And he just bought me lunch since I found it for him smile So let me rephrase that: Thanks for lunch!

    2025 年 8 月 25 日
    回复
  • saco de boxeo precio perú

    I am impressed with this website , real I am a big fan .

    2025 年 8 月 26 日
    回复
  • diamond painting

    But wanna remark that you have a very nice internet site, I like the design it really stands out.

    2025 年 8 月 26 日
    回复
  • google analytics alternative

    Google Analytics Alternative

    2025 年 8 月 29 日
    回复
  • razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
    取消回复
    • Linux / 6篇
    • Macos / 7篇
    • Windows / 9篇
    • 其他 / 9篇

    在路上 | 2024