0.10.5 • Published 4 years ago

youkuohao-gateway v0.10.5

Weekly downloads
-
License
-
Repository
-
Last release
4 years ago

Youkuohao Gateway


Features

  • HTTP(s)/WebScoket proxy
  • DNS
  • Service Registry
  • Domain router settings and indexes

Protocols

  • http(s)
  • lanproxy
  • redirect
  • urlproxy(s)
  • ws(s)

Docker Environments

NameTypeDefault ValueDescription
ACME_PRODUCTIONbooleanfalseACME should use production mode
NODE_ENVstringdevelopmentproduction or development
HTTPS_EMAILstring-email
API_HOSTstringlocalhostapi host, for example: api.youkuohao.com
DISABLE_DOCKERbooleanfalseif true, do not use docker
ENABLE_WEBSOCKETbooleantrue-
TASK_LOOP_PER_MSnumber5000Task loop gap

Docker Service Example

docker service create --name youkuohao-gateway \
  --mount type=bind,src=$PWD/,dst=/root/datadir \
  --mount type=bind,src=$PWD/.url-cached,dst=/root/.url-cached \
  --mount type=bind,src=$PWD/.npm-read,dst=/root/.npm-read \
  --env 'MAIN_URL=https://cdn.jsdelivr.net/npm/youkuohao-gateway@0.10.4-alpha.9/build/release/index.js' \
  --env 'ACME_PRODUCTION=true' \
  --env 'HTTPS_EMAIL=heineiuo@gmail.com' \
  --env 'API_HOST=api.youkuohao.com' \
  --env 'TASK_LOOP_PER_MS=10000' \
  --env 'DEBUG=true' \
  --env 'DATA_DIR=/root/datadir' \
  --network cms \
  --limit-cpu 0.5 \
  --publish 80:80 \
  --publish 443:443 \
  --publish 53:53/udp \
  docker.pkg.github.com/heineiuo/node-universal-runtime/node-universal-runtime:0.1.0

Proxy Design Doc

About API host

Proxy use domain (instead of IP address) as API host, it enables client request different Proxy Server to only one domain.

If client want to request a specified server with IP address, for example: request proxy.com but specify IP address as 220.19.10.12, the request can be:

curl -X GET 'http://proxy.com/v1/domain?ip=220.19.10.12'

In server side, if the server is not 220.19.10.12(Because of DNS), it will start proxy and send a request to 220.19.10.12, with host header:

curl -X GET 'http://220.19.10.12/v1/domain' -H host:proxy.com