Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/shfshanyue/whoami

Tiny node.js webserver that prints os information and HTTP request to output
https://github.com/shfshanyue/whoami

docker docker-image dockerfile http-server node serverless traefik-v2

Last synced: 2 months ago
JSON representation

Tiny node.js webserver that prints os information and HTTP request to output

Awesome Lists containing this project

README

        

# Whoami

![](https://img.shields.io/docker/pulls/shanyue/whoami)

受 [containous/whoami](https://github.com/containous/whoami) 启发,使用 nodejs 编写并无任何依赖的 whoami 服务。可用以测试 `docker`,`nginx` 及 `k8s` 服务等,另外也支持测试 `serverless`,如腾讯云与阿里云。以下是测试列表

+ : 山月的个人服务器,通过 `traefik` 及 `docker` 部署
+ : 腾讯云函数计算
+ : 阿里云函数计算 (将会自动下载 whoami 信息)

## Usage

+ `/*`: 返回 whoami 信息,包括服务器的 IP,hostname 信息及 http request headers
+ `/bench`: 返回 1,可用来做 benchmark
+ `/[?wait=d]`: 返回 whoami 信息,d 代表毫秒数,代表服务端延迟。在 Node 中使用一个 Promise 来实现

## Example

### Docker

``` bash
$ docker run -d -p 3333:3000 shanyue/whoami

$ curl http://0.0.0.0:3333
GET / HTTP/1.1
Hostname: 9cd2ede0d7a6
RemoteAddr: ::ffff:172.17.0.1:43740
IP: 127.0.0.1
IP: 172.17.0.2
User-Agent: curl/7.29.0
Host: localhost:3333
Accept: */*

```

### Traefik

``` bash
$ docker-compose up -d

$ curl https://who.shanyue.tech
```
### 腾讯云

关于腾讯云行数部署的更详细文章请参考以下两个仓库

+ [Serverless Http Component for Tencent Cloud](https://github.com/shfshanyue/serverless-http)
+ [中国云厂商 serverless framework 模板及示例 (更快的访问速度](https://github.com/shfshanyue/serverless-template-zh)

``` bash
$ npm install -g serverless

# 部署到腾讯云
$ sls

$ curl https://service-gweo1e2s-1257314149.gz.apigw.tencentcs.com/
```

### 阿里云

``` bash
$ npm install -g funcraft

# 部署到阿里云
$ fun deploy

$ curl http://ali-fun.shanyue.tech
```