Skip to content

Commit

Permalink
update NanoKVM-USB
Browse files Browse the repository at this point in the history
  • Loading branch information
wj-xiao committed Jan 22, 2025
1 parent b656425 commit 8605870
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 69 deletions.
95 changes: 62 additions & 33 deletions docs/hardware/en/kvm/NanoKVM_USB/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,38 @@ update:
- Release docs
---

## Download

Click to download the [Web Files](https://cdn.sipeed.com/nanokvm/NanoKVM-USB.zip) and unzip it. You'll get a folder named `NanoKVM-USB`.

## Generate Certificate
## Local deployment

> If only access through the local machine (localhost), certificates can be omitted.
Examples are provided here for Node.js and Python.

### Node.js Service

1. Open the terminal and enter the `NanoKVM-USB` directory in the previous step.
2. Execute `npm install -g http-server` to install `http-server`.
3. Execute `http-server -p 8080 -a localhost` to run the service.

### Python Service

1. Open the terminal and enter the `NanoKVM-USB` directory in the previous step.
2. Execute `python -m http.server 8080` to run the service.

### Visit on browser

After the service is started, open the browser and visit `http://localhost:8080`.

Note that you can only use the `http` protocol, not the `https` protocol.

## Local network deployment

> If access is needed within the local area network, a certificate is required.
Examples are provided here for Node.js and Python. The difference from the above is that a certificate is required.

### Generate Certificate

> Make sure you have `openssl` installed.
Expand All @@ -23,37 +50,10 @@ Click to download the [Web Files](https://cdn.sipeed.com/nanokvm/NanoKVM-USB.zip

After completion, two files `key.pem` and `cert.pem` will be generated in the current directory.

## Run Service

Examples are provided here for Node.js and Python.

### Node.js Service

1. Execute `npm install -g http-server` to install `http-server`.
2. Execute `http-server -S -C cert.pem -K key.pem` to run the service.
3. The address of the service can be found from the output log:

```shell
Starting up http-server, serving ./ through https

http-server version: 14.1.1

http-server settings:
CORS: disabled
Cache: 3600 seconds
Connection Timeout: 120 seconds
Directory Listings: visible
AutoIndex: visible
Serve GZIP Files: false
Serve Brotli Files: false
Default File Extension: none

Available on:
https://127.0.0.1:8080
https://192.168.3.250:8080
https://198.18.0.1:8080
Hit CTRL-C to stop the server
```
2. Execute `http-server -p 8080 -S -C cert.pem -K key.pem` to run the service.

### Python Service

Expand All @@ -77,10 +77,39 @@ httpd.serve_forever()

Execute `python server.py` to run the service。

## Visit on browser
### Visit on browser

Open the browser and enter the address obtained in the previous step. Here we take `https://127.0.0.1:8080` as an example.
Open the browser and enter the service address, such as `https://127.0.0.1:8080`.

After opening the URL, you may be prompted with a "Privacy Error" and need to click to access manually:

![](./../../../assets/NanoKVM/usb/privacy-error.png)

## Public network deployment

> If you need to access it on the public network, it is recommended to use `Nginx`.
Here is a simple configuration example. For detailed configuration methods, please refer to the `Nginx` documentation.

```nginx
server {
listen 80;
server_name your_domain.com www.your_domain.com; # Please replace with your domain name
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name your_domain.com www.your_domain.com; # Please replace with your domain name
root /var/www/your_website; # Please replace with the NanoKVM-USB directory path
index index.html index.htm;
ssl_certificate /etc/nginx/ssl/cert.pem; # Please replace it with your certificate file path
ssl_certificate_key /etc/nginx/ssl/key.pem; # Please replace it with your private key file path
location / {
try_files $uri $uri/ /index.html;
}
}
```
2 changes: 1 addition & 1 deletion docs/hardware/en/kvm/NanoKVM_USB/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Notably, NanoKVM-USB comes with a USB-A port that supports switching between HOS
| --- | :---: | :---: | :---: |
| HDMI Input | 4K@30fps | 1080P@60fps | 4K@30fps |
| HDMI Loopback | 4K@30fps | None | None |
| USB Capture | 1080P@60fps | 1080P@60fps | 1080P@60fps |
| USB Capture | 2K@30fps | 1080P@60fps | 1080P@60fps |
| USB Interface | USB3.0 | USB2.0 | USB3.0 |
| USB Switch | Y | Y | N |
| Keyboard&Mouse | Y | Y | Y |
Expand Down
100 changes: 65 additions & 35 deletions docs/hardware/zh/kvm/NanoKVM_USB/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,51 +9,52 @@ update:
- Release docs
---

## 下载文件

点击下载[网页文件](https://cdn.sipeed.com/nanokvm/NanoKVM-USB.zip),解压后会得到`NanoKVM-USB`文件夹。
首先,点击下载[网页文件](https://cdn.sipeed.com/nanokvm/NanoKVM-USB.zip),解压后会得到`NanoKVM-USB`文件夹。

## 生成证书
## 本机部署

> 首先请确保已安装 `openssl`
> 如果只需要通过本机访问(localhost),则可以不使用证书。
这里提供了 Node.js 和 Python 的示例。

### Node.js 服务

1. 打开终端,进入上一步骤中的 `NanoKVM-USB` 目录;
2. 执行 `npm install -g http-server` 安装 `http-server`
3. 执行 `http-server -p 8080 -a localhost` 启动服务。

### Python 服务

1. 打开终端,进入上一步骤中的 `NanoKVM-USB` 目录;
2. 执行 `python -m http.server 8080` 启动服务。

### 在网页中访问

服务启动后,打开浏览器访问 `http://localhost:8080` 即可。

注意只能使用`http`协议,无法使用`https`协议。

## 局域网部署

> 如果需要在局域网内访问,则需要使用证书。
这里提供了 Node.js 和 Python 的示例。相较于本地部署,多了一个生成证书的步骤。

### 生成证书

> 请确保已经安装 `openssl`
1. 打开终端,进入上一步骤中的 `NanoKVM-USB` 目录;
2. 执行 `openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem`
3. 终端会提示需要输入信息,可以一直按回车键跳过,也可以按自己的需要输入信息。

完成后会在当前目录生成两个文件:`key.pem``cert.pem`

## 启动本地服务

这里提供了 Node.js 和 Python 的示例。

### Node.js 服务

1. 执行 `npm install -g http-server` 安装 `http-server`;
2. 执行 `http-server -S -C cert.pem -K key.pem` 启动服务;
3. 服务启动后的日志输出如下,从日志中可以找到服务的地址:

```shell
Starting up http-server, serving ./ through https

http-server version: 14.1.1

http-server settings:
CORS: disabled
Cache: 3600 seconds
Connection Timeout: 120 seconds
Directory Listings: visible
AutoIndex: visible
Serve GZIP Files: false
Serve Brotli Files: false
Default File Extension: none

Available on:
https://127.0.0.1:8080
https://192.168.3.250:8080
https://198.18.0.1:8080
Hit CTRL-C to stop the server
```
2. 执行 `http-server -p 8080 -S -C cert.pem -K key.pem` 启动服务。

### Python 服务

Expand All @@ -77,10 +78,39 @@ httpd.serve_forever()

执行 `python server.py` 运行服务。

## 在网页中访问
### 在网页中访问

打开浏览器,输入在上一步骤中获取到的地址,这里以 `https://127.0.0.1:8080` 为示例
打开浏览器,输入服务地址,比如`https://127.0.0.1:8080`

打开网址后可能会提示`隐私错误`,需要手动点击访问:
如果打开网址后提示`隐私错误`,需要手动点击访问:

![](./../../../assets/NanoKVM/usb/privacy-error.png)

## 公网部署

> 如果需要在公网访问,建议使用 `Nginx`
这里给出一份简单的配置示例,详细的配置方式请参考 `Nginx` 文档。

```nginx
server {
listen 80;
server_name your_domain.com www.your_domain.com; # 请替换为您的域名
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name your_domain.com www.your_domain.com; # 请替换为您的域名
root /var/www/your_website; # 请替换为 NanoKVM-USB 目录路径
index index.html index.htm;
ssl_certificate /etc/nginx/ssl/your_domain.crt; # 请替换为您的证书文件路径
ssl_certificate_key /etc/nginx/ssl/your_domain.key; # 请替换为您的私钥文件路径
location / {
try_files $uri $uri/ /index.html;
}
}
```

0 comments on commit 8605870

Please sign in to comment.