Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ALBの疎通確認をWebサーバーなしでやる
Search
jhashimoto
June 18, 2026
Technology
120
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ALBの疎通確認をWebサーバーなしでやる
JAWS-UG 群馬 #35登壇資料
jhashimoto
June 18, 2026
More Decks by jhashimoto
See All by jhashimoto
SteampipeとExcel Power QueryでAWS構成定義書の作成を自動化する
jhashimoto
0
940
EdgeプロファイルでAWSアカウントを安全に使い分ける
jhashimoto
0
190
初めてのAWS / The first AWS
jhashimoto
0
320
AWS Data Pipelineを本番投入してみた話
jhashimoto
1
1.2k
AWS Lambdaで始めるサーバーレスアーキテクチャ
jhashimoto
0
280
Amazon S3の紹介
jhashimoto
0
310
クラウド最初の一歩
jhashimoto
0
430
Other Decks in Technology
See All in Technology
Hub & Spoke 環境のネットワークルーティングを分解してみる
tsuyataku
1
530
When Does a Local Qwen Start to Break
morshoto
0
180
Oracle Cloud Infrastructure IaaS 新機能アップデート 2026/6 - 2026/8
oracle4engineer
PRO
0
110
リージョンの壁を越える、 ちょっと変わったAWSサービスの話
falken
PRO
0
270
Redmine 7.0で私が開発した新機能の狙いと背景
vividtone
1
110
深夜のクラウド懺悔室 1:29:300 or 1:0:0
kazzpapa3
0
190
薬剤師(ドメインエキスパート)と一緒に育てる薬局向けAIアシスタント
kakehashi
PRO
2
110
AIとペアプロを始める。人とのペアプロをやめる。ペアプロの良さを改めて知る。もっと好きになった。 / Rediscovering Pair Programming
honyanya
1
270
Driving AI Adoption Using In-House GPUs to Serve Qwen
po3rin
2
460
Amazon S3 Tablesに全部任せてみた結果——コンパクション/スナップショット管理は本当に手放せるか
shigeruoda
0
410
PM領域でのAI Agentの活用
lycorptech_jp
PRO
0
270
振り返りこそエンジニアの本領
negima
0
320
Featured
See All Featured
HDC tutorial
michielstock
2
850
Designing for Performance
lara
611
70k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
810
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
890
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.3k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
920
[SF Ruby Conf 2025] Rails X
palkan
2
1.3k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.9k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
530
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.5k
Ruling the World: When Life Gets Gamed
codingconduct
0
320
Transcript
ALB の疎通確認をWeb サーバーなしでやる JAWS-UG 群馬 #35 10 分LT JAWS-UG 群馬
#35 1 / 14
発表者 橋本淳一 フリーランスのクラウドエンジニア 最近都内から栃木に引っ越しました 現在の仕事はEC サイトのインフラ運用 ポートフォリオ: https://lapras.com/public/jhashimoto JAWS-UG 群馬
#35 2 / 14
前提 インフラ担当とアプリ担当が別れている インフラ担当: ALB とEC2 の構築 アプリ担当: EC2 のOS より上のレイヤーを担当
インフラ担当としてALB -> EC2 の疎通確認をして引き渡したい JAWS-UG 群馬 #35 3 / 14
構成 以下の経路を想定。 クライアント │ HTTPS:443 ▼ ALB + ACM │
HTTP:8080 ▼ ターゲットグループ │ HTTP:8080 ▼ EC2インスタンス JAWS-UG 群馬 #35 4 / 14
目的 ALB にリクエストし、ターゲットからのレスポンスが返ることを確認したい ただし、Apache/Nginx 等のミドルウェアはインストールしたくない(インフラの 責務ではないから) テスト例: curl https://my-domain.com/ #
OK JAWS-UG 群馬 #35 5 / 14
問題 Web サーバーのミドルウェアがないとレスポンスが返せない ターゲットグループのヘルスチェックをパスする必要がある 例: ステータス200 を3 回連続で返したら、Healthy JAWS-UG 群馬
#35 6 / 14
案1: nc コマンド (1/2) nc コマンドのシンプルな使い方。 # サーバーで待ち受けておく nc -lk
8080 # クライアントからリクエスト echo "OK" | nc -q 0 {サーバーIP} 8080 -l : Listen モード -k : Keep inbound sockets open for multiple connects. 切断後も同じポートで次の 接続を待ち続ける -q 0 : quit after EOF on stdin and delay of secs. STDIN で EOF 後すぐに閉じる JAWS-UG 群馬 #35 7 / 14
案1: nc コマンド (2/2) 以下をターゲットで実行しておくと、ヘルスチェックをパスでき、リクエストに対し てレスポンスを返せる。 8080 でリッスンし、リクエストに対して200 を返す レスポンスを返した後も、リッスンが継続される
while true; do echo -e "HTTP/1.1 200 OK\r\nContent-Length: 3\r\n\r\nOK\n" | nc -l 8080 done # 以下のレスポンスを返す # HTTP/1.1 200 OK # Content-Length: 3 # # OK # JAWS-UG 群馬 #35 8 / 14
案2: Python でWeb サーバーを立てる (1/2) Python の組み込みHTTP サーバーなら、ワンライナーでHTTP サーバーを起動できる。 JAWS-UG
群馬 #35 9 / 14
案2: Python でWeb サーバーを立てる (2/2) PORT=8080 python3 -c " import
http.server, socketserver, os PORT = int(os.environ['PORT']) class Handler(http.server.BaseHTTPRequestHandler): def do_GET(self): self.send_response(200) self.end_headers() self.wfile.write(b'OK\n') def log_message(self, format, *args): pass # TCPサーバの終了直後にもう一度起動したときの「Address already in use」エラーを避ける # https://www.geekpage.jp/programming/winsock/so_reuseaddr.php socketserver.TCPServer.allow_reuse_address = True with socketserver.TCPServer(('', PORT), Handler) as httpd: print(f'Listening on port {PORT}') try: httpd.serve_forever() # Ctrl + C による KeyboardInterruptを抑制 except KeyboardInterrupt: pass " JAWS-UG 群馬 #35 10 / 14
補足: コマンド実行後にPORT 変数は参照されるか? A: 参照されないので、環境を汚さない コマンドの前に KEY=VALUE の形式で書くことを「パラメータ代入」と呼び(シェルの 機能) 、そのコマンドの実行中だけ環境変数として参照できる。
実験結果: $ PORT=8080 env | grep PORT # PORTを環境変数として参照できる PORT=8080 $ echo ${PORT} # コマンド実行後のシェル自身にはPORTが残っていない(何も出力されない) $ 参考: https://astro.uni-bonn.de/~sysstw/CompMan/gnu/bashref.html#TOC49 JAWS-UG 群馬 #35 11 / 14
リクエストしてみる ローカルホストにリクエストする。 curl http://localhost:8080/my-health-check-path # OK ターゲットのステータスが Healthy になったらドメインに対してリクエストする。 curl
https://my-domain.com/ # OK 確認が終わったら、ターミナルで Ctrl + C して HTTP サーバーを停止する。 JAWS-UG 群馬 #35 12 / 14
まとめ Web サーバーを構成していないターゲットでも、nc コマンドやPython の組み込み HTTP サーバーで疎通確認ができる nc コマンドは手軽だが、ヘルスチェックを通すにはHTTP レスポンスを自分で組み
立てる必要がある Python の組み込みHTTP サーバーなら、ワンライナーでもHTTP サーバーを起動でき る インフラ担当の責任範囲内(ミドルウェア追加なし)で、ALB -> EC2 の疎通確認 が完結できる JAWS-UG 群馬 #35 13 / 14
ありがとうございました JAWS-UG 群馬 #35 14 / 14