npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nrp

v0.1.1

Published

A reverse proxy written with node.js

Downloads

2

Readme

nrp

一个使用 Node.js 编写的反向代理服务器。

极简风格,支持 HTTPS,支持端口配置,支持子域名、多域名和多服务器。

安装

$ npm install -g nrp
or
$ sudo npm install -g nrp

配置

为了访问配置文件,需要知道 Node.js 环境的全局模块安装路径。

$ echo $NODE_PATH  # 查看环境变量
$ npm root -g  # 查看全局模块路径
$ npm get prefix  # 查看 prefix
$ NRP_PATH=`npm root -g`  # 设置 nrp 路径环境变量

假设需要代理服务器运行在 80 端口,www 主站和 blog 子站分别运行在本机端口 3000 和端口 4000,配置文件如下:

$ vi $NRP_PATH/nrp/config.json
{
  "port": 8080,
  "ssl": false,
  "key": "nrp-key.pem",
  "cert": "nrp-cert.pem",
  "www.name.com": {
    "host": "127.0.0.1",
    "port": 3000
  },
  "blog.name.com": {
    "host": "127.0.0.1",
    "port": 4000
  }
}

提示:HTTP 服务缺省端口是 80,HTTPS 是 443。使用 80 或 443 端口需要 sudo 权限。

密钥

为支持 HTTPS,需要 SSL 密钥文件,nrp 内置了自签名的 SSL 密钥文件。使用浏览器访问自签名 https 网站,需要选择信任。

可以修改配置文件 config.json 使用自己的密钥,也可以使用 openssl 重新生成自签名密钥。方法如下:

$ openssl genrsa -out nrp-key.pem 1024
$ openssl req -new -key nrp-key.pem -out nrp-cert.csr
$ openssl x509 -req -in nrp-cert.csr -signkey nrp-key.pem -out nrp-cert.pem

注意:密钥文件的位置,实际路径是 $NRP_PATH/nrp/lib/

启动

$ nrp
or
$ sudo nrp

简单 control + c 即可退出。

服务

可以使用 upstart 将 nrp 配置为系统服务,操作如下:

$ sudo vi /etc/init/nrp.conf

start on runlevel [2345]
stop on shutdown

respawn  # 自动重启
respawn limit 10 10  # 尝试10次,间隔10秒

script
    nrp 2>&1 >> /dev/null
end script

查看、启动或停止服务命令如下:

$ sudo status nrp  # 查看状态
$ sudo start nrp  # 启动服务
$ sudo stop nrp  # 停止服务

协议

MIT