Piping Serverを自前でホストする方法をいくつか
#Piping_Server #self_host
Piping Serverはどこの環境でも手軽に立てられるように心がけている。
そのため、いくつかサーバーを立てる方法を用意している。
その中から自分の環境で最短で立てられる方法を選べる。
セキュリティ・プライバシー的な目的で、
誰もがサーバーをセルフホストして自分のデータを自分で管理できるようにしている。
Piping Serverは分散的に運用されることを望んでいる。
リポジトリ:
方法1: Docker
以下でに立ち上がる。
code:bash
docker run -p 8181:8080 nwtgck/piping-server
自動再起動付き
永続的に動かすときは、以下のように-dでバッググラウンドで動かして、--restart=alwaysでマシンの再起動後もPiping Serverが起動してくれる。
code:bash
docker run -p 8181:80 -d --restart=always nwtgck/piping-server --http-port=80
方法2: Glitch
以下のGlitchでRemix Thisを押せばforkでき、
https://glitch.com/~piping
https://gyazo.com/e1235833c7edc21d4b8c0922737214f4
以下のShareのLive AppのURLが自分用のPiping Server。
https://gyazo.com/7234803d5addbc7561b92c78f88c2d05
(Glitchは無料で利用できる)
方法3: RunKit
以下のRunKitで"clone this notebook"で複製して、
https://runkit.com/nwtgck/piping
https://gyazo.com/05bbef17e1cf186bdfb94010d7cd0a35
以下のendpointをクリックすればば自分用のPiping Serverにアクセスできる。
https://gyazo.com/14bd2adf1eb2161bcc85f84de861a264
(RunKitは無料で利用できる。)
方法4: Repl.it
以下のRepl.itのURLからFork を押せばよい。
https://gyazo.com/a85a1802110fba75f7328147fdb04f15
方法5: npm
code:bash
# Install
npm install -g piping-server
# Run a server
piping-server
デフォルトでに立ち上がる。
以下のようにポートを指定することができる。
$ piping-server --http-port=80
方法6: npx
npxコマンドというnpmで配布されているコマンドをinstall -gせずに実行できるコマンドがある。
それを使うと以下のように簡単にPiping Serverを起動できる。
code:bash
npx piping-server
方法7: ワンバイナリ
ワンバイナリ・シングルバイナリ。
以下のようにしてに立ち上げる。
code:bash
wget https://github.com/nwtgck/piping-server-pkg/releases/download/v1.1.0/piping-server-linux
chmod +x piping-server-linux
./piping-server-linux --http-port=8888
内部でzeit/pkgを使ってワンバイナリを生成している。
バイナリはGitHub Releaseに置いている。
Rust版のPiping Serverではより軽量なワンバイナリを提供している:
https://github.com/nwtgck/piping-server-rust/releases
方法8: Heroku(非ストリーミング)
以下のURLに行って、
nwtgck/piping-server - Buttons - Heroku Elements
以下のDeploy to Heroku ボタンで無料でHerokuにデプロイできる。
https://gyazo.com/974cf5bfe514b0d4cf4ed749fd02d035
方法9: Cloud Run(非ストリーミング)
Cloud RunでPiping Serverを立てる方法と注意点と解決策
SSL証明書付きでHTTPS
自己署名証明書でPiping ServerをDocker上に立てる
Let's Encryptとの利用でも上記が使える。
余談: オプション一覧
以下がpiping-serverで指定できるオプション。
piping-server --helpで取得可能。
code:Piping Serverのオプション一覧
Options:
--help Show help boolean
--version Show version number boolean
--http-port Port of HTTP server default: 8080
--enable-https Enable HTTPS default: false
--https-port Port of HTTPS server number
--key-path Private key path string
--crt-path Certification path string
認証や使える人を絞るときの方法
以下は使える人を限定したい時に使う方法。
Basic認証付きのPiping Serverを立てる方法
Auth0での認証付きのPiping Serverを立てる
公開されたPiping Serverを知っている人のみが使えるように限定公開する