### Install NPS Server (Windows)
Source: https://github.com/ehang-io/nps/blob/master/README.md
Run this command in an administrator command prompt on Windows to install NPS as a system service. Navigate to the NPS installation directory first.
```bash
nps.exe install
```
--------------------------------
### Download and Install NPS Server
Source: https://context7.com/ehang-io/nps/llms.txt
Download the NPS server binary, extract it, and install it as a system service on your public-facing machine. Configuration file is located at /etc/nps/conf/nps.conf.
```bash
# Download from releases
wget https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_server.tar.gz
tar -xzf linux_amd64_server.tar.gz
cd linux_amd64_server
# Install as system service (Linux/macOS)
sudo ./nps install
# Start the server
sudo nps start
# Stop the server
sudo nps stop
# Check version
./nps -version
# Configuration file location: /etc/nps/conf/nps.conf
# Default web port: 8080
# Default bridge port: 8024
# Default credentials: admin/123
```
--------------------------------
### Download and Install NPS Client
Source: https://context7.com/ehang-io/nps/llms.txt
Download the NPC client binary, extract it, and connect to the NPS server. It can be run in no-config mode or installed as a system service. Configuration can also be managed via a config file.
```bash
# Download from releases
wget https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_client.tar.gz
tar -xzf linux_amd64_client.tar.gz
cd linux_amd64_client
# Connect to server (no config file mode)
./npc -server=1.1.1.1:8024 -vkey=your_client_vkey
# Install as system service
sudo ./npc install -server=1.1.1.1:8024 -vkey=your_client_vkey
sudo npc start
# Or use config file mode
./npc -config=/path/to/npc.conf
```
--------------------------------
### Start NPS Server (Linux/macOS)
Source: https://github.com/ehang-io/nps/blob/master/README.md
Start the NPS server service on Linux or macOS. Administrator privileges are required.
```bash
sudo nps start
```
--------------------------------
### Install NPS as a System Service (Windows)
Source: https://github.com/ehang-io/nps/blob/master/docs/use.md
Register the NPS client as a system service on Windows by running the command as an administrator. This enables automatic startup and daemonization.
```powershell
npc.exe install 其他参数(例如-server=xx -vkey=xx或者-config=xxx)
```
--------------------------------
### NPS HTTP Proxy Configuration Example
Source: https://github.com/ehang-io/nps/blob/master/docs/use.md
Configuration for setting up an HTTP proxy. This allows NPS to act as an HTTP proxy, forwarding requests from a specified server port.
```ini
[common]
server_addr=1.1.1.1:8024
vkey=123
[http]
mode=httpProxy
server_port=9003
```
--------------------------------
### NPS Global Configuration Example
Source: https://github.com/ehang-io/nps/blob/master/docs/use.md
Example of the global configuration section in an NPS configuration file. This section defines essential connection parameters and general settings.
```ini
[common]
server_addr=1.1.1.1:8024
conn_type=tcp
vkey=123
username=111
password=222
compress=true
crypt=true
rate_limit=10000
flow_limit=100
remark=test
max_conn=10
#pprof_addr=0.0.0.0:9999
```
--------------------------------
### Start NPS Server (Windows)
Source: https://github.com/ehang-io/nps/blob/master/README.md
Start the NPS server service on Windows. Execute this command in an administrator command prompt from the NPS program directory.
```bash
nps.exe start
```
--------------------------------
### Install NPS Server (Linux/macOS)
Source: https://github.com/ehang-io/nps/blob/master/README.md
Execute this command on Linux or macOS to install NPS as a system service. Ensure you have administrator privileges.
```bash
sudo ./nps install
```
--------------------------------
### NPS Client Configuration Example
Source: https://context7.com/ehang-io/nps/llms.txt
Example configuration for the NPC client (npc.conf). This file defines common settings and various tunnel types like domain proxy, TCP, UDP, HTTP proxy, SOCKS5, secret, P2P, and file server.
```ini
[common]
server_addr=1.1.1.1:8024
conn_type=tcp
vkey=your_client_vkey
auto_reconnection=true
max_conn=1000
flow_limit=1000
rate_limit=1000
compress=true
crypt=true
disconnect_timeout=60
# Optional: Connect through proxy
# proxy_url=socks5://user:pass@127.0.0.1:1080
# Domain proxy (HTTP reverse proxy)
[web1]
host=app.example.com
target_addr=127.0.0.1:8080,127.0.0.1:8081
host_change=www.internal.local
header_set_proxy=nps
# TCP tunnel (SSH access)
[ssh_tunnel]
mode=tcp
target_addr=192.168.1.100:22
server_port=9022
# UDP tunnel (DNS forwarding)
[dns_tunnel]
mode=udp
target_addr=192.168.1.1:53
server_port=5353
# HTTP proxy
[http_proxy]
mode=httpProxy
server_port=8888
# SOCKS5 proxy
[socks5_proxy]
mode=socks5
server_port=1080
multi_account=multi_account.conf
# Secret proxy (no exposed port)
[secret_ssh]
mode=secret
password=unique_secret_key
target_addr=192.168.1.100:22
# P2P tunnel (direct connection)
[p2p_ssh]
mode=p2p
password=unique_p2p_key
target_addr=192.168.1.100:22
# File server
[file_server]
mode=file
server_port=9100
local_path=/var/www/files
strip_pre=/files/
```
--------------------------------
### NPS Domain Proxy Configuration Example
Source: https://github.com/ehang-io/nps/blob/master/docs/use.md
Configuration for setting up a domain proxy. This allows NPS to handle incoming HTTP/HTTPS requests for a specified domain and forward them to internal services. Load balancing is supported.
```ini
[common]
server_addr=1.1.1.1:8024
vkey=123
[web1]
host=a.proxy.com
target_addr=127.0.0.1:8080,127.0.0.1:8082
host_change=www.proxy.com
header_set_proxy=nps
```
--------------------------------
### NPS Server Configuration Example
Source: https://context7.com/ehang-io/nps/llms.txt
Example configuration for the NPS server (nps.conf). This file defines proxy ports, bridge settings, web interface, authentication, P2P settings, logging, and feature toggles.
```ini
appname = nps
runmode = pro
# HTTP(S) proxy ports for domain resolution
http_proxy_ip=0.0.0.0
http_proxy_port=80
https_proxy_port=443
https_just_proxy=true
https_default_cert_file=conf/server.pem
https_default_key_file=conf/server.key
# Bridge settings (server-client communication)
bridge_type=tcp
bridge_port=8024
bridge_ip=0.0.0.0
# Public vkey for config file mode clients
public_vkey=your_secret_key
# Web management interface
web_host=nps.example.com
web_username=admin
web_password=secure_password_here
web_port=8080
web_ip=0.0.0.0
web_open_ssl=false
# Web API authentication (16 chars required)
auth_key=your_api_auth_key
auth_crypt_key=1234567812345678
# P2P settings
p2p_ip=1.1.1.1
p2p_port=6000
# Logging (0=Emergency to 7=Debug)
log_level=3
# Feature toggles
allow_user_login=false
allow_user_register=false
allow_flow_limit=true
allow_rate_limit=true
allow_tunnel_num_limit=true
allow_local_proxy=false
allow_connection_num_limit=true
allow_multi_ip=false
system_info_display=true
# Port whitelist
allow_ports=9001-9009,10001,11000-12000
# HTTP cache for static files
http_cache=true
http_cache_length=100
# Client disconnect timeout (unit: 5s, default 60 = 5 minutes)
disconnect_timeout=60
```
--------------------------------
### Install NPS as a System Service (Linux/macOS)
Source: https://github.com/ehang-io/nps/blob/master/docs/use.md
Register the NPS client as a system service for automatic startup and daemonization on Linux and macOS. Ensure you stop the client first if it's already running.
```bash
sudo ./npc install 其他参数(例如-server=xx -vkey=xx或者-config=xxx)
```
--------------------------------
### NPS SOCKS5 Proxy Configuration Example
Source: https://github.com/ehang-io/nps/blob/master/docs/use.md
Configuration for setting up a SOCKS5 proxy. This allows NPS to act as a SOCKS5 proxy, forwarding requests from a specified server port. Multi-account support is available via a configuration file.
```ini
[common]
server_addr=1.1.1.1:8024
vkey=123
[socks5]
mode=socks5
server_port=9004
multi_account=multi_account.conf
```
--------------------------------
### NPS UDP Tunnel Configuration Example
Source: https://github.com/ehang-io/nps/blob/master/docs/use.md
Configuration for establishing a UDP tunnel. This forwards UDP traffic from a specified server port to an internal target address.
```ini
[common]
server_addr=1.1.1.1:8024
vkey=123
[udp]
mode=udp
target_addr=127.0.0.1:8080
server_port=9002
```
--------------------------------
### Configure NPC via Environment Variables
Source: https://context7.com/ehang-io/nps/llms.txt
Use environment variables for configuration in containerized environments or automated setups. Supports direct execution or template-based config files.
```bash
# No config file mode - set environment variables
export NPC_SERVER_ADDR=1.1.1.1:8024
export NPC_SERVER_VKEY=your_secret_vkey
# Simply run npc without arguments
./npc
# Config file mode with environment variable templating
cat > /etc/npc/npc.conf << 'EOF'
[common]
server_addr={{.NPC_SERVER_ADDR}}
conn_type=tcp
vkey={{.NPC_SERVER_VKEY}}
auto_reconnection=true
[web]
host={{.NPC_WEB_HOST}}
target_addr={{.NPC_WEB_TARGET}}
EOF
# Set the variables
export NPC_SERVER_ADDR=1.1.1.1:8024
export NPC_SERVER_VKEY=abc123
export NPC_WEB_HOST=app.example.com
export NPC_WEB_TARGET=127.0.0.1:8080
# Run with config file (variables auto-rendered)
./npc -config=/etc/npc/npc.conf
# Docker example
docker run -d --name npc --net=host \
-e NPC_SERVER_ADDR=1.1.1.1:8024 \
-e NPC_SERVER_VKEY=abc123 \
ffdfgdfg/npc
```
--------------------------------
### Run NPS Client Without Configuration File
Source: https://github.com/ehang-io/nps/blob/master/docs/use.md
Use this command to run the NPS client when all configurations are managed via the server's web interface. No additional client setup is required beyond this command.
```bash
./npc -server=ip:port -vkey=web界面中显示的密钥
```
--------------------------------
### NPS File Access Configuration Example
Source: https://github.com/ehang-io/nps/blob/master/docs/use.md
Configuration for enabling file access mode, which exposes local files as a public service. This mode requires the client to be running in configuration file mode. It specifies the server port, local path, and a prefix for URL access.
```ini
[common]
server_addr=1.1.1.1:8024
vkey=123
[file]
mode=file
server_port=9100
local_path=/tmp/
strip_pre=/web/
```
--------------------------------
### NPS P2P Proxy Configuration Example
Source: https://github.com/ehang-io/nps/blob/master/docs/use.md
Configuration for a peer-to-peer (P2P) proxy mode, also suitable for secure access like SSH. It uses a unique password for authentication and defines the internal target address.
```ini
[common]
server_addr=1.1.1.1:8024
vkey=123
[p2p_ssh]
mode=p2p
password=ssh2
target_addr=10.1.50.2:22
```
--------------------------------
### NPS TCP Tunnel Configuration Example
Source: https://github.com/ehang-io/nps/blob/master/docs/use.md
Configuration for establishing a TCP tunnel. This forwards TCP traffic from a specified server port to an internal target address.
```ini
[common]
server_addr=1.1.1.1:8024
vkey=123
[tcp]
mode=tcp
target_addr=127.0.0.1:8080
server_port=9001
```
--------------------------------
### Run NPS Client With Configuration File
Source: https://github.com/ehang-io/nps/blob/master/docs/use.md
Launch the NPS client using a specified configuration file. This mode allows for client-side configuration and management.
```bash
./npc -config=npc配置文件路径
```
--------------------------------
### Configure SOCKS5 Proxy with Authentication
Source: https://context7.com/ehang-io/nps/llms.txt
Set up a SOCKS5 proxy with authentication using a separate configuration file for user credentials. Update the main NPC config to reference the authentication file.
```bash
# With authentication (multi_account.conf)
cat > /etc/npc/multi_account.conf << 'EOF'
user1:password1
user2:password2
EOF
# Update npc.conf
# multi_account=multi_account.conf
curl --socks5 user1:password1@1.1.1.1:1080 http://internal-site.local
```
--------------------------------
### Display Target String
Source: https://github.com/ehang-io/nps/blob/master/web/views/index/hedit.html
Placeholder to display the target string in the configuration.
```Go Template
{{.h.Target.TargetStr}}
```
--------------------------------
### Configure HTTP Proxy via Client Config File
Source: https://context7.com/ehang-io/nps/llms.txt
Set up an HTTP forward proxy using a client configuration file. This allows access to internal HTTP/HTTPS websites through the proxy.
```bash
# Client config for HTTP proxy on port 8888
cat > /etc/npc/npc.conf << 'EOF'
[common]
server_addr=1.1.1.1:8024
vkey=abc123
[http_proxy]
mode=httpProxy
server_port=8888
EOF
./npc -config=/etc/npc/npc.conf
```
--------------------------------
### Initialize Bootstrap Table for Client Management
Source: https://github.com/ehang-io/nps/blob/master/web/views/client/list.html
Configures the Bootstrap Table with server-side pagination, custom detail views, and column definitions for client data.
```javascript
/*bootstrap table*/ $('#table').bootstrapTable({ toolbar: "#toolbar", method: 'post', // 服务器数据的请求方式 get or post url: "{{.web_base_url}}/client/list", // 服务器数据的加载地址 contentType: "application/x-www-form-urlencoded", striped: true, // 设置为true会有隔行变色效果 search: true, showHeader: true, showColumns: true, showRefresh: true, pagination: true,//分页 sidePagination: 'server',//服务器端分页 pageNumber: 1, pageList: [5, 10, 20, 50],//分页步进值 detailView: true, smartDisplay: true, // 智能显示 pagination 和 cardview 等 onExpandRow: function () {$('body').setLang ('.detail-view');}, onPostBody: function (data) { if ($(this)[0].locale != undefined ) $('body').setLang ('#table'); }, detailFormatter: function (index, row, element) { return ': ' + row.MaxConn + ' ' + ': ' + row.NowConn + ' ' + ': ' + row.Flow.FlowLimit + 'm ' + ': ' + row.RateLimit + 'kb/s ' + ': ' + row.MaxTunnelNum + '
' + ': ' + row.WebUserName + ' ' + ': ' + row.WebPassword + ' ' + ': ' + row.Cnf.U + ' ' + ': ' + row.Cnf.P + '
' + ': ' + ': ' + ':
' + ': ' + "./npc{{.win}} -server={{.ip}}:{{.p}} -vkey=" + row.VerifyKey + " -type=" +{{.bridgeType}} +"" }, //表格的列 columns: [ { field: 'Id',//域值 title: '',//标题 halign: 'center', visible: true//false表示不显示 }, { field: 'Remark',//域值 title: '',//标题 halign: 'center', visible: true//false表示不显示 }, { field: 'Version',//域值 title: '',//标题 halign: 'center', visible: true//false表示不显示 }, { field: 'VerifyKey',//域值 title: '',//标题 halign: 'center', visible: true,//false表示不显示 formatter: function (value, row, index) { if (!row.NoStore) { return value } else { return '' } } }, { field: 'Addr',//域值 title: '',//标题 halign: 'center', visible: true//false表示不显示 }, { field: 'InletFlow',//域值 title: '',//标题 halign: 'center', visible: true,//false表示不显示 sortable: true,//启用排序 formatter: function (value, row, index) { return changeunit(row.Flow.InletFlow) } }, { field: 'ExportFlow',//域值 title: '',//标题 halign: 'center', visible: true,//false表示不显示 sortable: true,//启用排序 formatter: function (value, row, index) { return changeunit(row.Flow.ExportFlow) } }, { field: 'IsConnect',//域值 title: '',//内容 halign: 'center', visible: true,//false表示不显示 formatter: function (value, row, index) { return changeunit(row.Rate.NowRate) + "/S" } }, { field: 'Status',//域值 title: '',//内容 align: 'center', halign: 'center', visible: true,//false表示不显示 formatter: function (value, row, index) { if (value) { return '' } else { return '' } } }, { field: 'IsConnect',//域值 title: '',//内容 align: 'center', halign: 'center', visible: true,//false表示不显示 formatter: function (value, row, index) { if (value) { return '' } else { return '' } } }, { field: 'option',//域值 title: '',//内容 align: 'center', halign: 'center', visible: true,//false表示不显示 formatter: function (value, row, index) { btn_group = '