<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Worawut.J(worwae) on Medium]]></title>
        <description><![CDATA[Stories by Worawut.J(worwae) on Medium]]></description>
        <link>https://medium.com/@j-wor?source=rss-874ea6838138------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*y_ch9FCiN4irrhsfOMVhUA.jpeg</url>
            <title>Stories by Worawut.J(worwae) on Medium</title>
            <link>https://medium.com/@j-wor?source=rss-874ea6838138------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 08:04:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@j-wor/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[One Key, Many Minds: รวม AI Provider ทุกค่ายไว้ใน API เดียวด้วย 9Router]]></title>
            <link>https://j-wor.medium.com/one-key-many-minds-%E0%B8%A3%E0%B8%A7%E0%B8%A1-ai-provider-%E0%B8%97%E0%B8%B8%E0%B8%81%E0%B8%84%E0%B9%88%E0%B8%B2%E0%B8%A2%E0%B9%84%E0%B8%A7%E0%B9%89%E0%B9%83%E0%B8%99-api-%E0%B9%80%E0%B8%94%E0%B8%B5%E0%B8%A2%E0%B8%A7%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-9router-5eed6a1db0c4?source=rss-874ea6838138------2</link>
            <guid isPermaLink="false">https://medium.com/p/5eed6a1db0c4</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Worawut.J(worwae)]]></dc:creator>
            <pubDate>Thu, 16 Jul 2026 03:01:04 GMT</pubDate>
            <atom:updated>2026-07-16T03:01:04.320Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*k5rFM-pDi_lE2via" /><figcaption>ภาพปกสร้างด้วย Codex gpt-5.4 image ผ่าน 9Router โดยใช้ reference image จาก logo จริงของ 9Router + provider ต่างๆ</figcaption></figure><blockquote><em>บทความนี้ focus การเพิ่ม provider หลายค่ายใน 9Router ตั้งแต่เริ่มต้น พร้อมเปิด features ประหยัด token สุดฮิตอย่าง RTK, Headroom, Caveman, Ponytail</em></blockquote><h3>ปัญหาที่ความเจ็บปวดจริง</h3><ul><li>เดือนนึงจ่าย subscription Claude Code $20, GitHub Copilot $10, Cursor $20 — โควต้าเหลือไม่ใช้ก็หมดอายุ</li><li>Rate limit กระหน่ำมาตอนเขียนโค้ดหนัก</li><li>tool_result (git diff, ls, grep, log dump) กิน token ไป 30-50% ทุก request</li><li>ใช้หลาย provider แต่ SDK ไม่เหมือนกัน, format ไม่เหมือนกัน, dashboard ไม่เหมือนกัน</li></ul><h3>9Router แก้ยังไง</h3><p>9Router คือ AI gateway ตัวเดียวโผล่ adopter OpenAI-compatible REST เหนือ provider ทั้งหมด. มี token-saver features ที่บีบอั้นจริง:</p><ul><li>✅ <strong>RTK Token Saver</strong> — บีบอัด tool_result before ส่ง MCP, ประหยัด 20-40% input tokens</li><li>✅ <strong>Headroom Token Saver</strong> — การบีบอัด context layer อัด file/tool outputs อัตโนมัติ</li><li>✅ <strong>Caveman Mode</strong> — inject caveman-speak prompt → MCP ตอบสั้น เอาแต่งานจริง leave room, ประหยัด 65% output tokens</li><li>✅ <strong>Ponytail (Lazy Senior Dev)</strong> — inject “lazy senior dev” prompt → MCP เขียน不可或缺 YAGNI-first โค้ดน้อย + ไม่มี abstraction เกินจำเป็น</li><li>✅ <strong>Smart 3-Tier Fallback</strong> — Subscription → Cheap → Free, zero downtime</li><li>✅ <strong>Real-time Quota Tracking</strong> — ใช้ทุก drop ก่อน reset</li></ul><h3>เริ่มตั้งแต่ศูนย์: Setup แบบทีละขั้น</h3><h3>ขั้นที่ 1: รัน 9Router</h3><pre># Docker หรือ Podman (rootless ได้)<br>podman run -d --name 9router \<br>  -p 20128:20128 \<br>  -v ~/.9router:/data \<br>  ghcr.io/decolua/9router:latest</pre><pre># ตรวจสอบ<br>curl &lt;http://localhost:20128/api/health&gt;<br># → {&quot;ok&quot;:true}</pre><p>Dashboard ที่ <a href="http://localhost:20128/">http://localhost:20128</a></p><h3>ขั้นที่ 2: เพิ่ม Provider Accounts</h3><p>Dashboard → <strong>Accounts</strong> เพิ่มทีละตัว:</p><p><strong>OAuth (Subscription):</strong></p><ul><li>Claude Code → ล็อกอิน OAuth (free unlimited + $20/mo plan)</li><li>Codex → OAuth</li><li>GitHub Copilot → OAuth</li><li>Cursor → OAuth</li></ul><p><strong>API Key:</strong></p><ul><li>OpenAI → ใส่ key จาก <a href="http://platform.openai.com/">platform.openai.com</a></li><li>Anthropic → ใส่ key จาก <a href="http://console.anthropic.com/">console.anthropic.com</a></li><li>Gemini → ใส่ key จาก <a href="http://aistudio.google.com/">aistudio.google.com</a></li><li>GLM → ใส่ key ($0.6/1M tokens — ถูก)</li><li>Ollama (local) → URL http://localhost:11434 (ไม่ต้องใช้ key, ฟรี)</li></ul><p><strong>Free:</strong></p><ul><li>Kiro AI → Claude 4.5 + GLM-5 + MiniMax unlimited ฟรี (ไม่ต้อง signup)</li><li>OpenCode Free → no auth, auto-fetch models</li></ul><p>แต่ละ provider สามารถเพิ่มได้หลาย account — เช่น Claude Code 2 accounts เพื่อ round-robin</p><h3>ขั้นที่ 3: สร้าง API Key หนึ่งตัว</h3><p>Dashboard → <strong>Keys</strong> → สร้าง sk-...</p><pre>export NINEROUTER_URL=&quot;&lt;http://localhost:20128&gt;&quot;<br>export NINEROUTER_KEY=&quot;sk-...&quot;</pre><p>Key ตัวเดียวทุก client ใช้. ไม่ต้องจำ key ของแต่ละ provider อีก</p><h3>ขั้นที่ 4: เชื่อม CLI Tool ของคุณ</h3><p>9Router รองรับ Claude Code, Codex, OpenClaw, Cursor, Cline, Continue, Copilot, Roo, Kilo Code, Antigravity, OpenCode — ทุกตัวที่ customize OpenAI endpoint ได้</p><pre># Claude Code example:<br>Endpoint: &lt;http://localhost:20128/v1&gt;<br>API Key:  sk-... (จาก Dashboard)<br>Model:    cc/claude-sonnet-4.5</pre><h3>ขั้นที่ 5: ตรวจสอบ Models ที่ใช้ได้</h3><pre>curl $NINEROUTER_URL/v1/models | jq &#39;.data[].id&#39;<br># → cc/claude-opus-4-6, cc/claude-sonnet-4.5<br># → codex/gpt-5.5, cx/gpt-5.4-image<br># → glm/glm-4.7<br># → kr/claude-sonnet-4.5 (Kiro, free)<br># → ollama/llama3.3<br># → ...</pre><h3>Token Saver Features: ประหยัดจริง 20–65%</h3><h3>RTK Token Saver (⭐40K GitHub)</h3><p>Tool outputs (git diff, grep, ls, tree, log dumps) มักกิน 30-50% ของ prompt budget. RTK บีบอัด lossless before ส่ง LLM:</p><pre>Without RTK: 47K tokens sent to LLM<br>With RTK:    28K tokens sent to LLM   (40% saved · same context · same answer)</pre><p>Filters อัตโนมัติ: git-diff, git-status, grep, find, ls, tree, dedup-log, smart-truncate</p><ul><li>Auto-detect: แค่ peek 1KB แรกของ tool_result → เลือก filter เอง</li><li>Safe: filter ล้มเหลว → ส่ง original ไม่ break request</li><li>Default ON — เปิด/ปิด ได้ใน Dashboard → Endpoint settings</li></ul><h3>Headroom Token Saver</h3><p>Headroom เป็น proxy แยกที่ 9Router เรียก /v1/compress ก่อน route request:</p><pre>Client → 9Router → Headroom /v1/compress → 9Router → provider</pre><pre>pip install &quot;headroom-ai[proxy]&quot;<br>headroom proxy --port 8787</pre><p>Enable ใน Dashboard → Endpoint → Token Saver → Headroom. ค่า default <a href="http://localhost:8787/">http://localhost:8787</a></p><p>ถ้า Headroom ล่ม → 9Router ส่ง original (fail open)</p><h3>Caveman Mode (⭐52K GitHub)</h3><p>Inject caveman-speak system prompt → LLM ตอบสั้นกระชับ เอาแต่งานจริง ไม่มี filler/hedging:</p><pre>Without Caveman: &quot;Sure! I&#39;d be happy to help you with that. The issue you&#39;re experiencing is likely caused by...&quot;<br>                  (147 tokens)</pre><pre>With Caveman:    &quot;Bug in auth middleware. Token expiry check use `&lt;` not `&lt;=`. Fix:&quot;<br>                  (15 tokens · same technical content)</pre><p>ประหยัด <strong>65% output tokens</strong>. เปิดใน Dashboard → Endpoint → Caveman</p><h3>Ponytail (Lazy Senior Dev)</h3><p>Inject “lazy senior dev” prompt → LLM เขียนโค้ด YAGNI-first: ไม่มี abstraction เกินจำเป็น, ใช้ stdlib ก่อน new deps, one-liner ดีกว่า 5 บรรทัด:</p><ul><li><strong>Lite</strong> — เขียนตามที่ขอ + บอกทางขี้เกียจกว่า</li><li><strong>Full</strong> — YAGNI ladder: stdlib → native → existing deps → one-liner → minimal code</li><li><strong>Ultra</strong> — YAGNI extremist: deletion first, ตั้งคำถาม requirement ใน response เดียวกัน</li></ul><pre>Without Ponytail: verbose code, extra abstractions, &quot;just in case&quot; scaffolding<br>With Ponytail:    shortest working diff, no unrequested abstractions, fewer tokens</pre><p>Never trades away: input validation, error handling, security, หรืออะไรที่ขอ explicit. เปิดใน Dashboard → Endpoint → Ponytail. ใช้คู่กับ Caveman + RTK ได้</p><h3>Smart 3-Tier Fallback: ไม่มีหยุดทำงาน</h3><pre>Combo: &quot;my-coding-stack&quot;<br>  1. cc/claude-opus-4-6        (subscription)<br>  2. glm/glm-4.7               ($0.6/1M, cheap backup)<br>  3. kr/claude-sonnet-4.5      (Kiro, free fallback)</pre><pre>→ quota หมด → switch อัตโนมัติ<br>→ provider ล่ม → switch อัตโนมัติ<br>→ error → retry next tier</pre><h3>ใช้จริงใน Homelab ของผม</h3><ul><li><strong>Hermes Agent</strong> (AI operator บน Telegram) → ทุก LLM call ผ่าน 9Router</li><li><strong>Cover image สำหรับบทความ Medium</strong> → Gemini/Codex image gen ผ่าน 9Router (ภาพปกบทความนี้สร้างด้วย 9Router เอง)</li><li><strong>Web search</strong> → Tavily ผ่าน 9Router</li><li><strong>Vision</strong> → Qwen-3 ผ่าน 9Router</li><li>RTK + Caveman เปิดตลอด → ประหยัด token ไปเยอะ</li></ul><h3>สรุป</h3><p>ก่อน 9Router หลัง 9Router 3+ SDK, 3+ API keys 1 key, 1 endpoint token หมดไปกับ tool_result 30-50% RTK บีบอัดให้เหลือ 20-40% LLM ตอบยืดยาว filler เยอะ Caveman บีบ output 65% โค้ดมี abstraction เกินจำเป็น Ponytail YAGNI-first โค้ดน้อย Provider ล่ม → โค้ดพัง Auto-fallback 3 tier โควต้าหมดไปเปล่า ดู quota real-time + maximize</p><p>ลองได้ที่ <a href="https://github.com/decolua/9router">GitHub: decolua/9router</a> — open source, free</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5eed6a1db0c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ขุดแล็ปท็อปเก่ามาลง Hermes Agent]]></title>
            <link>https://j-wor.medium.com/%E0%B8%82%E0%B8%B8%E0%B8%94%E0%B9%81%E0%B8%A5%E0%B9%87%E0%B8%9B%E0%B8%97%E0%B9%87%E0%B8%AD%E0%B8%9B%E0%B9%80%E0%B8%81%E0%B9%88%E0%B8%B2%E0%B8%A1%E0%B8%B2%E0%B8%A5%E0%B8%87-hermes-agent-a1eab548bb92?source=rss-874ea6838138------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1eab548bb92</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Worawut.J(worwae)]]></dc:creator>
            <pubDate>Thu, 02 Jul 2026 03:01:38 GMT</pubDate>
            <atom:updated>2026-07-02T03:01:38.591Z</atom:updated>
            <content:encoded><![CDATA[<p>ขุดแล็ปท็อปเก่ามาลง Hermes Agent — ทำไงให้เครื่อง spec ต่ำกลายเป็น AI Operator ส่วนตัว</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*2PL37YMd6snnHiAbya-d2A@2x.jpeg" /></figure><blockquote><em>โจทย์คือ มี ThinkPad Edge เครื่องเก่า CPU 2 core RAM 4GB จะเอามาทำอะไรดีที่ไม่ใช่แค่เก็บไว้กินฝุ่น — อยากได้ AI Operator ส่วนตัวที่คุยผ่าน Telegram ได้ ควบคุม smart home และมี CI/CD pipeline ในตัว</em></blockquote><h3>Spec เครื่องที่ใช้</h3><p>ThinkPad Edge 01 — Ubuntu 26.04, CPU 2 cores, RAM 4 GB, Disk 100 GB, Podman rootless</p><h3>Problem Statement</h3><p>เครื่อง spec ต่ำแบบนี้:</p><ul><li>K8s/GitLab เต็มรูปแบบคงไม่ไหว</li><li>Docker แบบ root ต้องใช้ sudo — ไม่สะดวก</li><li>อยากได้ server ส่วนตัวที่รันได้ 24/7 โดยไม่กินไฟ</li><li>อยาก automate ชีวิต — morning briefing, smart home, deploy code</li></ul><h3>Solution</h3><p>เลือก stack นี้:</p><ul><li><strong>Podman rootless</strong> — ไม่ต้อง sudo, ปลอดภัยกว่า, resource น้อยกว่า Docker</li><li><strong>Quadlet systemd</strong> — container เป็น service auto-start/restart</li><li><strong>Hermes Agent</strong> — AI operator ที่รันผ่าน Telegram, มี skills system</li><li><strong>C ockpit + Netdata</strong> — observability ตั้งแต่แรก</li></ul><h3>Implement</h3><h3>Step 1: ตั้งค่า Podman rootless</h3><p>อย่างแรกคือ alias docker → podman ให้ docker-compose files เดิมใช้ได้</p><pre>alias docker=podman<br>alias docker-compose=&quot;podman-compose&quot;<br>loginctl enable-linger<br>systemctl --user enable --now podman-restart.service</pre><h3>Step 2: ติดตั้ง Base Services</h3><p>ลง Cockpit (web admin), Nginx (reverse proxy), Netdata (monitoring):</p><pre>sudo apt install cockpit -y<br>sudo systemctl enable --now cockpit.socket<br>podman run -d --name netdata -p 19999:19999 --restart=always netdata/netdata</pre><blockquote><em>Tip: ลง monitoring ก่อน deploy service แรก — อย่ารอให้พังแล้วค่อยดู</em></blockquote><h3>Step 3: ติดตั้ง Hermes Agent</h3><pre>curl -LsSf &lt;https://github.com/NousResearch/hermes/releases/latest/download/hermes-installer.sh&gt; | sh<br>hermes config set telegram.token &quot;YOUR_BOT_TOKEN&quot;<br>hermes tools enable homeassistant</pre><p>Hermes ไม่ใช่แค่ chatbot — มันเป็น <strong>AI operator</strong> ที่:</p><ul><li>รัน cron jobs ได้ (morning briefing ทุกวัน 06:30)</li><li>ควบคุม smart home ผ่าน Home Assistant tools</li><li>เขียนโค้ด deploy monitor ได้เอง</li><li>มี skills system — โหลด workflow เฉพาะงานได้</li></ul><h3>Step 4: สร้าง CI/CD Pipeline</h3><p>AI War Room dashboard มี pipeline แบบนี้:</p><pre>cd ~/projects/ai-war-room<br>npm run test:e2e  # 12/12 passing<br>rsync -avz dist/ ~/.local/share/war-room-dashboard/<br>systemctl --user restart war-room-dashboard.service</pre><blockquote><em>Pitfall: </em><em>podman restart ทำลาย pasta port forwarding — ต้องใช้ </em><em>systemctl --user start/stop แทน</em></blockquote><h3>Step 5: ตั้งค่า Morning Briefing</h3><p>สร้าง cron job ที่รันทุกวัน 06:30 ผ่าน Hermes cronjob tool — ไม่ต้องเขียน script เอง</p><h3>ผลลัพธ์</h3><p><strong>สิ่งที่ได้บน RAM 3GB:</strong></p><ul><li>Hermes AI Agent 🟢 — คุยผ่าน Telegram</li><li>Home Assistant 🟢 — smart home hub</li><li>War Room Dashboard 🟢 — CI/CD status</li><li>Netdata 🟢 — real-time monitoring</li><li>Cockpit 🟢 — web admin</li></ul><p>ระบบยังเหลือ RAM 2GB+ — สบายมาก</p><h3>บทเรียนสำคัญ</h3><p><strong>1. Spec ต่ำ ≠ ใช้งานไม่ได้</strong></p><p>RAM 3GB กับ 2 cores พอสำหรับ container services ตัวเล็ก ๆ ได้สบาย K8s/GitLab เต็มรูปแบบคงไม่ไหว แต่ Podman rootless + Quadlet systemd ใช้ทรัพยากรน้อยมาก</p><p><strong>2. Podman Rootless + Quadlet = Game Changer</strong></p><p>เปลี่ยนจาก Docker → Podman rootless ทำให้ไม่ต้องใช้ sudo รัน container, Quadlet ทำให้ container เป็น systemd service auto-start/restart</p><p>⚠️ podman restart ทำลาย pasta port forwarding — ใช้ systemctl --user start/stop แทน</p><p><strong>3. Observability ก่อนทุกอย่าง</strong></p><p>ลง Netdata + Cockpit ตั้งแต่แรก — ทำให้เห็นว่าเครื่องใช้ resource ยังไง, container ตัวไหนมีปัญหา</p><p><strong>4. CI/CD บนเครื่องเล็ก ๆ ก็ทำได้</strong></p><p>ใช้ sandbox container สำหรับ test — แยก environment ออกจาก production</p><p><strong>5. Smart Home Integration Problem</strong></p><ul><li>Tuya HA เปิดแค่ temp/humidity sensor — ไม่มี IR command entities</li><li>HA 2026.5 WebSocket API เปลี่ยน — config flow commands ใช้ไม่ได้ ต้องใช้ REST</li><li>HA .storage/auth token = hashed — ใช้เป็น Bearer token ไม่ได้</li></ul><p><strong>6. Terminal Tool มี False Positive</strong></p><p>คำสั่งที่มีคำว่า “uvicorn” trigger server-detection error — ต้อง workaround</p><h3>Adoption Journey</h3><ul><li><strong>Day 1:</strong> ลง Homelab base (Podman, Cockpit, Nginx, Netdata)</li><li><strong>Week 1:</strong> Deploy Hermes + Telegram integration</li><li><strong>Week 2:</strong> เชื่อม Home Assistant + Smart Home</li><li><strong>Week 3:</strong> สร้าง CI/CD pipeline + E2E tests</li><li><strong>Week 4:</strong> เขียน skills + cron jobs</li></ul><h3>สรุป</h3><p>การ POC ครั้งนี้จุดประสงค์เพื่อพิสูจน์ว่าเครื่อง spec ต่ำสามารถเป็น server ส่วนตัวที่ใช้งานจริงได้ พบว่า Podman rootless + Hermes Agent ค่อนข้างตอบโจทย์ — resource usage ต่ำ, automation ได้ดี, maintain ง่าย</p><p>ในส่วนของ Smart Home integration อาจจะต้องระวังเรื่อง API changes แต่ละ version ของ HA แต่ถ้าดูถึงความคุ้มค่าจะเห็นว่าจะมีค่าใช้จ่ายที่ถูกมาก — แค่ค่าไฟเดือนละไม่กี่บาท</p><h3>Resources</h3><ul><li><strong>Hermes Agent</strong>: <a href="https://github.com/NousResearch/hermes">https://github.com/NousResearch/hermes</a></li><li><strong>Podman</strong>: <a href="https://podman.io/">https://podman.io</a></li><li><strong>Quadlet</strong>: <a href="https://docs.podman.io/en/latest/markdown/podman-systemd.unit.5.html">https://docs.podman.io/en/latest/markdown/podman-systemd.unit.5.html</a></li><li><strong>Netdata</strong>: <a href="https://www.netdata.cloud/">https://www.netdata.cloud</a></li><li><strong>Home Assistant</strong>: <a href="https://www.home-assistant.io/">https://www.home-assistant.io</a></li></ul><h3>ภาคต่อ</h3><p>เรื่องนี้ยังไม่จบ — ภาคต่อจะเป็นการทำ autonomous DevOps Hermes Agent แบบเต็มตัว ตั้งแต่ orchestration, automation, monitoring, ไปจนถึง workflow ที่รันเองได้จริง</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1eab548bb92" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[# DevOps แบบไม่ Over-Engineer — เริ่มยังไงให้ทีมไม่เกลียด]]></title>
            <link>https://j-wor.medium.com/devops-%E0%B9%81%E0%B8%9A%E0%B8%9A%E0%B9%84%E0%B8%A1%E0%B9%88-over-engineer-%E0%B9%80%E0%B8%A3%E0%B8%B4%E0%B9%88%E0%B8%A1%E0%B8%A2%E0%B8%B1%E0%B8%87%E0%B9%84%E0%B8%87%E0%B9%83%E0%B8%AB%E0%B9%89%E0%B8%97%E0%B8%B5%E0%B8%A1%E0%B9%84%E0%B8%A1%E0%B9%88%E0%B9%80%E0%B8%81%E0%B8%A5%E0%B8%B5%E0%B8%A2%E0%B8%94-286f288bfbc8?source=rss-874ea6838138------2</link>
            <guid isPermaLink="false">https://medium.com/p/286f288bfbc8</guid>
            <dc:creator><![CDATA[Worawut.J(worwae)]]></dc:creator>
            <pubDate>Fri, 26 Jun 2026 14:47:59 GMT</pubDate>
            <atom:updated>2026-06-26T14:47:59.504Z</atom:updated>
            <content:encoded><![CDATA[<h3># DevOps แบบไม่ Over-Engineer — เริ่มยังไงให้ทีมไม่เกลียด</h3><p>หลายทีมอยากทำ DevOps แต่เริ่มผิดทาง <br>ยังไม่ทันรู้ว่าปัญหาตัวเองคืออะไร ก็เลือก tool ก่อนแล้ว <br>สุดท้ายไม่ได้ DevOps — ได้ “DevOops” แทน</p><p>ผมเคยผ่านช่วงนั้นเหมือนกันครับ <br>และนี่คือบทสรุปแบบไม่หลอกตัวเอง สำหรับคนที่อยากเริ่ม DevOps แบบใช้งานได้จริง</p><p>— -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sDzDNBpWmW7JEJbvg0Z4iw.png" /></figure><p>## ❌ ความเข้าใจผิดที่ทำให้ DevOps พังตั้งแต่วันแรก</p><p>| ความเชื่อผิด | ผลลัพธ์จริง |<br>| — — — — — — — -| — — — — — — |<br>| DevOps = ต้องมี tool เยอะ | ทีมเหนื่อยกับการ maintain แต่ไม่รู้ว่ามันช่วยอะไร |<br>| Automate ทุกอย่าง = ดี | Automate ของที่ยังไม่เข้าใจ → พังไวกว่าเดิม |<br>| DevOps = งานของทีม DevOps | ทีมอื่นไม่ร่วมมือ → pipeline ไม่มีวัน flow |</p><p>**ข้อเท็จจริง:** <br>DevOps ไม่ใช่ชื่อทีม หรือ tool stack <br>มันคือ **วิธีทำงานร่วมกันแบบลด friction ระหว่าง Dev กับ Ops**</p><p>— -</p><p>## 🟢 แล้วควรเริ่มยังไงให้ไม่เกลียดกัน?</p><p>### 1) เริ่มจากปัญหา ไม่ใช่จากเครื่องมือ</p><p>ถามคำถามนี้ก่อน:</p><p>- เราช้าเพราะ build?<br>- deploy แล้ว production พัง?<br>- ไม่มี test?<br>- ต้อง remote แก้สดทุกครั้ง?</p><p>**ปัญหา คือ จุดเริ่มต้นจริงของ DevOps** <br>**Tool แค่ implementation** — ไม่ใช่เป้าหมาย</p><p>— -</p><p>### 2) ทำ Pipeline เดียวที่ทุกคนเข้าใจ</p><p>ไม่ต้อง fancy ไม่ต้องมี stage complex <br>เริ่มจาก 4 ขั้นตอนนี้ให้ “รอดก่อน”</p><p>Commit Code →<br> Run Test →<br> Build Artifact →<br> Deploy</p><p>Pipeline ที่ชัดเจน = ความเร็ว + ความมั่นใจ <br>ไม่ใช่จำนวน dashboard หรือชื่อ tool</p><p>— -</p><p>### 3) Automate เฉพาะสิ่งที่ซ้ำ และได้ผลเร็ว</p><p>DevOps ไม่ได้เกิดจาก automation <br>แต่เกิดจาก **ความชัดเจน + ความร่วมมือ**</p><p>เริ่ม 3 ชั้นนี้ตามลำดับ:</p><p>| ขั้น | เป้าหมาย | ตัวอย่าง |<br>| — — -| — — — — — | — — — — -|<br>| ❶ Standardize | ทำงานเหมือนกัน | branch policy, naming, deploy guide |<br>| ❷ Visibility | เห็นปัญหาได้ทันที | pipeline status, alert, log |<br>| ❸ Automate | ลด manual step | test, build, deploy |</p><p>ถ้าครั้น ❶ ยังไม่มี <br>Terraform + Ansible + ArgoCD ก็ไม่ช่วยอะไร</p><p>— -</p><p>### 4) DevOps ไม่ใช่งานของ “ใครบางคน”</p><p>ถ้า DevOps ทำทุกอย่าง → DevOps กลายเป็น bottleneck</p><p>สิ่งที่ควรเป็นคือ shared ownership:</p><p>- Dev ทำ test และ code ที่ deploy ได้<br>- Ops ทำ infra ที่ automate ได้<br>- ทุกทีมร่วมกันรับผิดชอบ production</p><p>นี่แหละ DevOps ที่แท้จริง <br>ไม่ใช่แค่ตั้งทีมแล้วแปะชื่อ</p><p>— -</p><p>## 🔥 ทำไมแนวนี้ได้ผล</p><p>เพราะมัน:</p><p>- ไม่บังคับให้ทีมเปลี่ยนเยอะเกินไป<br>- ไม่ overspend กับ tool ที่ยังไม่จำเป็น<br>- ได้ผลเร็ว → ทีมเริ่มเห็นประโยชน์ → พร้อมพัฒนาเพิ่มเอง<br>- scale ขึ้นได้ตาม maturity ไม่ใช่ตาม hype</p><p>หลายองค์กรล้มเหลว เพราะอยากเป็น Netflix <br>ทั้งที่ปัญหายังเป็นระดับ “deploy แล้วลุ้น”</p><p>— -</p><p>## 🎯 takeaway สำคัญ</p><p>&gt; DevOps ไม่ได้เริ่มจาก Kubernetes <br>&gt; DevOps เริ่มจาก pipeline ที่ทุกคนเข้าใจ <br>&gt; แล้วค่อยโตไปทีละขั้น</p><p>— -</p><p>## 🙋🏻‍♂️ ถ้าคุณเริ่ม DevOps วันนี้ อย่าเริ่มจาก tool</p><p>อย่าถามว่า <br>**“เราควรใช้อะไรดี?”**</p><p>จงถามว่า <br>**“ทีมเรายังติดตรงไหน?”**</p><p>ตอบคำถามนี้ให้ได้ก่อน <br>แล้ว tool ที่ใช่จะเดินมาหาคุณเอง</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=286f288bfbc8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[บันทึกเรื่อง POC static html ด้วยNext.js ตามสไตล์ DevOps ตอนที่ 1]]></title>
            <link>https://j-wor.medium.com/%E0%B8%9A%E0%B8%B1%E0%B8%99%E0%B8%97%E0%B8%B6%E0%B8%81%E0%B9%80%E0%B8%A3%E0%B8%B7%E0%B9%88%E0%B8%AD%E0%B8%87-poc-static-html-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2next-js-%E0%B8%95%E0%B8%B2%E0%B8%A1%E0%B8%AA%E0%B9%84%E0%B8%95%E0%B8%A5%E0%B9%8C-devops-%E0%B8%95%E0%B8%AD%E0%B8%99%E0%B8%97%E0%B8%B5%E0%B9%88-1-7dde69e1d1ec?source=rss-874ea6838138------2</link>
            <guid isPermaLink="false">https://medium.com/p/7dde69e1d1ec</guid>
            <category><![CDATA[static-websites]]></category>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Worawut.J(worwae)]]></dc:creator>
            <pubDate>Wed, 09 Nov 2022 04:40:45 GMT</pubDate>
            <atom:updated>2022-11-09T04:40:45.651Z</atom:updated>
            <content:encoded><![CDATA[<p>Build and deploy static html to AWS s3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*LWJmI28bT2qS2pGB90ZhXw.png" /></figure><blockquote>โจทย์คือ ต้องการจะสร้าง static website เพื่อทำ SPA หรือ pre-order page</blockquote><h3>Problem statement:</h3><p>- ต้องหลีกเลี่ยงการออกแบบ dynamic website ที่พึ่งพา web server<br>- ต้องใช้จ่ายงบอย่างเหมาะสม</p><h3>Solution:</h3><p>- เลือกใช้งาน build static html file ด้วย Next.js<br>- deploy html file ไว้บน s3</p><h3>Implement:</h3><h4>Step 1: สร้าง project Next.js กันก่อน</h4><pre>$npx create-next-app</pre><p>เพิ่ม step การ build html file เข้าไปใน package.json</p><pre>&quot;build&quot;: &quot;next build &amp;&amp; next export&quot;</pre><p>จากนั้นสั่ง build เราจะได้ static html พร้อมสำหรับ deploy แล้ว</p><pre>$yarn build</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*wSVUrJjITBAiL7RJ9mXmNg.png" /></figure><h4>Step 2: สร้าง s3 bucket บน AWS กัน โดยเริ่มจาก เลือกไปที่ menu <strong>create s3 bucket</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*ChRAg-dLK4cMbEslZ2YaKA.png" /></figure><p>uncheck <strong>block all public access</strong> ออกก่อน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*ad5w00fSlHK0zEGBWlLC2A.png" /></figure><h4>Step 3: สร้าง User Access สำหรับใช้ access s3 bucket</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*yRTTX9neOZkBKyXhuAUZiA.png" /></figure><p>ทำการ attach existing policy โดย filter ตามด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*2b2GuPwzeAg2liRilxhS4Q.png" /></figure><h4>Step 4: install และ setup เครื่องมือ AWS CLI</h4><p>เมื่อเราทำการ download และ install AWS CLI เรียบร้อยแล้ว ให้ run command configure แล้วทำตามคำสั่งของ program เพื่อ setup user, credential ให้กับ environment</p><pre>$aws configure</pre><p>จากนั้นลอง run command s3 ls ดูว่าเราเห็น s3 bucket ที่เราได้ create ไว้ก่อนหน้าหรือไม่</p><pre>$aws s3 ls</pre><h4>Step 5: ตั้งค่า bucket สำหรับ web hosting</h4><p>เข้าไปที่ aws console เลือก menu s3 เพื่อเลือก bucket ที่สร้างไว้ตอนแรก จากนั้นไปที่ tab properties → Static website hosting → edit</p><ul><li>Static website hosting เลือก <strong>Enable</strong></li><li>Hosting type เลือก <strong>Host a static website</strong></li><li>Index document ให้ใส่ <strong>index.html </strong>ส่วน error จะใส่หรือไม่ใส่ก็ได้</li><li>จากนั้น <strong>Save</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kGomTcKyil_ZSTsF4SpHAg.png" /></figure><p>ต่อไปเข้าไปที่ tab Permission → <strong>Bucket policy</strong> แล้วกด edit</p><ul><li>ใส่ json parameters ลงไปตามด้านล่าง (อย่าลืมเปลี่ยนชื่อ bucket ด้วย)</li></ul><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Principal&quot;: &quot;*&quot;,<br>            &quot;Action&quot;: &quot;s3:GetObject&quot;,<br>            &quot;Resource&quot;: &quot;arn:aws:s3:::[[bucket-name]]/*&quot;<br>        }<br>    ]<br>}</pre><h4>Step 6: config ให้ Next.Js deploy file ไปยัง s3</h4><p>กลับมาที่ project Next.Js อีกครั้ง และเพิ่ม deploy เข้าไป</p><pre>&quot;deploy&quot;:&quot;aws s3 sync out/ s3://[[bucket-name]]&quot;</pre><p>จากรนั้นลองสั่ง deploy</p><pre>$yarn deploy</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uutji43vf50Nw46r7Iu18g.png" /></figure><p>จากนั้นกดเข้าไปดูที่ s3 → Objects จะเห็นว่า file web ได้ถูก upload ขึ้นมาบน s3 เรียบร้อยแล้ว</p><h3>ทดสอบ:</h3><p>ที่ menu s3 ให่เข้าไปที่ tab properties เหมือนเดิม จากนั้นเลื่อนลงมาดูที่ Static website hosting และดู URL สำหรับเปิด public website ที่ Bucket website endpoint</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vps1j2uu4idbs3D3g_-zsw.png" /></figure><p>เราจะเห็น website run เรียบร้อย จบบบบ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*Q9y1k_yPChvBILIxvXznaQ.png" /></figure><h3>สรุป:</h3><p>การ POC ครั้งนี้จุดประสงค์เเพื่อนำไปใช้งานจริงบน production พบว่า Framework Next.Js ค่อนข้างจะตอบโจทย์การใช้งานและ configure ได้ง่ายมากๆ ในส่วนของ AWS s3 อาจจะมีหลายขั้นตอนหน่อยที่อาจจะต้องอาศัยความชำนาญระดับนึง แต่ถ้าดูถึงความคุ้มค่าจะเห็นว่าจะมีค่าใช้จ่ายที่ถูกมากๆ</p><p>อย่างไรก็ตามการ POC ครั้งนี้ก็ยังไม่เสร็จสมบูรณ์ซะทีเดียว เพราะเรายังไม่ได้พูดถึง DNS Routing, CDN, CI/CD ที่จะมาช่วยตอบโจทย์ความต้องการในแง่ของ user experience และการวางแผนการ release ในแต่ละ change (CI/CD) เพราะงั้น.. โปรดติดตามดูกันต่อไปนะ…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7dde69e1d1ec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[มาทำ JWT authorization ด้วย OpenResty กัน]]></title>
            <link>https://j-wor.medium.com/%E0%B8%A1%E0%B8%B2%E0%B8%97%E0%B8%B3-jwt-authorization-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-openresty-redis-%E0%B8%81%E0%B8%B1%E0%B8%99-e3d7547e95ee?source=rss-874ea6838138------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3d7547e95ee</guid>
            <category><![CDATA[openresty]]></category>
            <category><![CDATA[lua]]></category>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[nginx]]></category>
            <dc:creator><![CDATA[Worawut.J(worwae)]]></dc:creator>
            <pubDate>Thu, 02 Sep 2021 14:29:43 GMT</pubDate>
            <atom:updated>2021-09-02T14:43:57.159Z</atom:updated>
            <content:encoded><![CDATA[<h3>จากบทความก่อน</h3><p>ที่เราลองได้มาเริ่มทำ <a href="https://j-wor.medium.com/%E0%B8%A1%E0%B8%B2%E0%B8%97%E0%B8%B3api-gateway-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-openresty-%E0%B8%81%E0%B8%B1%E0%B8%99%E0%B9%80%E0%B8%96%E0%B8%AD%E0%B8%B0-%E0%B8%95%E0%B8%AD%E0%B8%99%E0%B8%97%E0%B8%B5%E0%B9%88-1-ffc8f7b97381"><strong>API Gateway ด้วย OpenResty</strong></a><strong> </strong>ก็พองจะมองเห็นพลังความสามารถของ lua script ได้ประมาณนึง มาบทความนี้เราจะมาจริงจังกับการทำ API gateway with JWT authorization กัน ดูซิว่าจะเจ๋งซักแค่ไหน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/1*KSIq5PJzAsHhgWxj5ptpyg.png" /></figure><h3>เริ่มต้น</h3><p>เราจะ design API gateway JWT authorization แต่จะขอข้ามเรื่อง <strong>OAuth </strong>ไปก่อนนะ (<em>อาจจะหาอ่านกันเองได้</em>) ซึ่ง flow การทำงานคร่าวๆ ก็จะประมาณนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*zVZlWdV_cJzRgPAOQUxNgw.png" /><figcaption><a href="https://sequencediagram.org/">https://sequencediagram.org</a></figcaption></figure><h4>จาก sequence diagram แบบคร่าวๆ จะเห็นว่า</h4><ol><li>เมื่อมีการขอใช้ Resource API จำเป็นต้องใช้ token ถึงจะใช้งานได้ เพราะหากไม่ส่ง token ไปด้วย เจ้า Openresty ก็จะ response 401 Unauthorize ออกมาให้เลย</li><li>จากข้อ 1 ถ้าไม่มี token ก็อยากจะมี token บ้างใช่มั้ย งั้นขอมาสิ โดยส่ง user,pass เข้ามา ถ้า Authenticate API ตรวจสอบว่า okay อนุญาติให้ใช้งานได้ ก็จะ generate token ให้นะ</li><li>พอได้ token มาแล้วก็จัดเลย ด้วยการขอ Resource API แล้วแนบ token ไปด้วย จากนั้น openresty ก็แค่ตรวจว่า token ถูกต้องหรือไม่ ถ้าตรวจแล้วถูกต้องก็ proxy pass ไปหา Resource API ได้เลย <strong>จบ !!</strong></li></ol><h3>มา How to กัน</h3><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*lyLn5OLl6i241Twg.png" /></figure><blockquote>ในบทความนี้จะพูดถึงในส่วนของ openresty อย่างเดียว ไม่ได้พูดถึง authenticate API นะ ซึ่งสามารถ implement ได้หลากหลายภาษามาก ถ้าอยากรู้ ก็ตามไปดูได้ที่ <a href="https://jwt.io/"><em>JSON Web Tokens — jwt.io</em></a></blockquote><p>รอบก่อน เราเคยพูดกันไปแล้วว่า openresty ใช้ภาษา lua ในการเขียน pre-script ดังนั้น lib ต่างๆ มันจึงเลยค่อนข้างพร้อมใช้ได้เลย</p><h4>งั้นมา install JWT lib กันก่อน (<em>อันนี้คือผม build ด้วย docker นะ)</em></h4><pre><strong>RUN /usr/local/openresty/luajit/bin/luarocks install lua-resty-jwt</strong> </pre><h4>เสร็จเรามาเขียน function กัน</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dseti%26wt%3Dnone%26l%3Dlua%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dlocal%252520jwt%252520%25253D%252520require%252520%252522resty.jwt%252522%25250Alocal%252520validators%252520%25253D%252520require%252520%252522resty.jwt-validators%252522%25250A%25250Alocal%252520claim_spec%252520%25253D%252520%25257B%25250A%252520%252520%252520%252520%252520validators.set_system_leeway%252815%2529%25252C%252520--%252520time%252520in%252520seconds%25250A%252520%252520%252520%252520%252520exp%252520%25253D%252520validators.is_not_expired%2528%2529%25252C%25250A%252520%252520%252520%252520%252520iat%252520%25253D%252520validators.is_not_before%2528%2529%25250A%25257D&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dseti%26wt%3Dnone%26l%3Dlua%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dlocal%25252520jwt%25252520%2525253D%25252520require%25252520%25252522resty.jwt%25252522%2525250Alocal%25252520validators%25252520%2525253D%25252520require%25252520%25252522resty.jwt-validators%25252522%2525250A%2525250Alocal%25252520claim_spec%25252520%2525253D%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520validators.set_system_leeway%25252815%252529%2525252C%25252520--%25252520time%25252520in%25252520seconds%2525250A%25252520%25252520%25252520%25252520%25252520exp%25252520%2525253D%25252520validators.is_not_expired%252528%252529%2525252C%2525250A%25252520%25252520%25252520%25252520%25252520iat%25252520%2525253D%25252520validators.is_not_before%252528%252529%2525250A%2525257D&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0308cd1bb556919630edbc386594fe5a/href">https://medium.com/media/0308cd1bb556919630edbc386594fe5a/href</a></iframe><p>step แรกคือมาเขียน<strong> claim_spec </strong>กันก่อน ก็คือ require jwt และ method validators เข้ามาและเขียน spec ตามตัวอย่าง</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dseti%26wt%3Dnone%26l%3Dlua%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dlocal%252520token%252520%25253D%252520nil%25250Afunction%252520f_gettoken%2528%2529%25250A%252520%252520%252520%252520auth_header%252520%25253D%252520ngx.var.http_Authorization%25250A%252520%252520%252520%252520if%252520auth_header%252520then%25250A%252520%252520%252520%252520%252520%252520%252520%252520_%25252C%252520_%25252C%252520token%252520%25253D%252520string.find%2528auth_header%25252C%252520%252522Bearer%252525s%25252B%2528.%25252B%2529%252522%2529%25250A%252520%252520%252520%252520end%25250A%252520%252520%252520%252520return%252520token%25250Aend&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dseti%26wt%3Dnone%26l%3Dlua%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dlocal%25252520token%25252520%2525253D%25252520nil%2525250Afunction%25252520f_gettoken%252528%252529%2525250A%25252520%25252520%25252520%25252520auth_header%25252520%2525253D%25252520ngx.var.http_Authorization%2525250A%25252520%25252520%25252520%25252520if%25252520auth_header%25252520then%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520_%2525252C%25252520_%2525252C%25252520token%25252520%2525253D%25252520string.find%252528auth_header%2525252C%25252520%25252522Bearer%25252525s%2525252B%252528.%2525252B%252529%25252522%252529%2525250A%25252520%25252520%25252520%25252520end%2525250A%25252520%25252520%25252520%25252520return%25252520token%2525250Aend&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f020933285fe8c1391e7e6e7e5267b0/href">https://medium.com/media/1f020933285fe8c1391e7e6e7e5267b0/href</a></iframe><p>ต่อมามาเขียน function เพื่อ get token จาก header parameter กัน ซึ่งในที่นี้ header parameter request จะเป็น <strong><em>authorization : Bearer &lt;JWT token&gt;</em></strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dseti%26wt%3Dnone%26l%3Dlua%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%25250Alocal%252520jwt_obj%252520%25253D%252520jwt%25253Averify%2528%252522%25253Cprivatekey%25253E%252522%25252C%252520token%25252C%252520claim_spec%2529%25250Aif%252520not%252520jwt_obj%25255B%252522verified%252522%25255D%252520then%25250A%252520%252520%252520%252520ngx.status%252520%25253D%252520ngx.HTTP_UNAUTHORIZED%25250A%252520%252520%252520%252520ngx.header.content_type%252520%25253D%252520%252522application%25252Fjson%25253B%252520charset%25253Dutf-8%252522%25250A%252520%252520%252520%252520ngx.say%2528%252522%25257B%25255C%252522status%25255C%252522%25253A%25257B%25255C%252522Code%25255C%252522%25253A%252520%25255C%252522401%25255C%252522%25252C%25255C%252522Desc%25255C%252522%25253A%252520%25255C%252522%252522%252520..%252520jwt_obj.reason%252520..%252520%252522%25255C%252522%25257D%25257D%252522%2529%25250A%252520%252520%252520%252520ngx.exit%2528ngx.HTTP_UNAUTHORIZED%2529%25250Aend&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dseti%26wt%3Dnone%26l%3Dlua%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3D%2525250Alocal%25252520jwt_obj%25252520%2525253D%25252520jwt%2525253Averify%252528%25252522%2525253Cprivatekey%2525253E%25252522%2525252C%25252520token%2525252C%25252520claim_spec%252529%2525250Aif%25252520not%25252520jwt_obj%2525255B%25252522verified%25252522%2525255D%25252520then%2525250A%25252520%25252520%25252520%25252520ngx.status%25252520%2525253D%25252520ngx.HTTP_UNAUTHORIZED%2525250A%25252520%25252520%25252520%25252520ngx.header.content_type%25252520%2525253D%25252520%25252522application%2525252Fjson%2525253B%25252520charset%2525253Dutf-8%25252522%2525250A%25252520%25252520%25252520%25252520ngx.say%252528%25252522%2525257B%2525255C%25252522status%2525255C%25252522%2525253A%2525257B%2525255C%25252522Code%2525255C%25252522%2525253A%25252520%2525255C%25252522401%2525255C%25252522%2525252C%2525255C%25252522Desc%2525255C%25252522%2525253A%25252520%2525255C%25252522%25252522%25252520..%25252520jwt_obj.reason%25252520..%25252520%25252522%2525255C%25252522%2525257D%2525257D%25252522%252529%2525250A%25252520%25252520%25252520%25252520ngx.exit%252528ngx.HTTP_UNAUTHORIZED%252529%2525250Aend&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5dc6a2832588b5b24a3ef2e60a67ff99/href">https://medium.com/media/5dc6a2832588b5b24a3ef2e60a67ff99/href</a></iframe><p>จากนั้นมาเขียน verify token กันต่อ โดยส่ง token ที่เรา get ได้เมื่อกี้นี้เข้ามา validate ที่ method นี้ โดยจะ verify JWT ว่าตรงตาม format ที่ generate ไปหรือเปล่า โดยจะเอา <strong>private key</strong> ที่ตั้งไว้ไป validate จากนั้นจะทำการ check <strong>exp </strong>ว่าหมดอายุไปหรือยัง</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dseti%26wt%3Dnone%26l%3Dyaml%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dlocation%252520%25252Fresource%252520%25257B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520access_by_lua_file%252520%25252Fetc%25252Fnginx%25252Flua%25252Fvalidatetoken.lua%25253B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520default_type%252520%252520application%25252Fjson%25253B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520%252520proxy_pass%252520http%25253A%25252F%25252Fresource%25252Fapi%25253B%25250A%252520%252520%252520%252520%252520%252520%252520%252520%25257D&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dseti%26wt%3Dnone%26l%3Dyaml%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dlocation%25252520%2525252Fresource%25252520%2525257B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520access_by_lua_file%25252520%2525252Fetc%2525252Fnginx%2525252Flua%2525252Fvalidatetoken.lua%2525253B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520default_type%25252520%25252520application%2525252Fjson%2525253B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520proxy_pass%25252520http%2525253A%2525252F%2525252Fresource%2525252Fapi%2525253B%2525250A%25252520%25252520%25252520%25252520%25252520%25252520%25252520%25252520%2525257D&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c5f9eb3c558db83da5d8ee40e1bde32/href">https://medium.com/media/0c5f9eb3c558db83da5d8ee40e1bde32/href</a></iframe><p>เสร็จแล้วก็มา add rule ใส่ nginx กัน เพื่อให้ location นี้ต้องผ่านการตรวจสอบ JWT token ก่อนเท่านั้น ถึงจะอนุญาติให้ proxy_pass ไปหา resource API ได้</p><pre>access_by_lua_file /etc/nginx/lua/validatetoken.lua;</pre><p><strong>เป็นอันจบ !!</strong></p><h3>สรุปกัน</h3><p>จาก solution ในการเพิ่มความสามารถของ <strong>openresty </strong>ให้สามารถทำหน้าที่เป็นเหมือน authorize gateway ได้โดยไม่ต้องไปซื้อบริการ authentication service provider ต่างๆ ซึ่งอาจช่วยลดค่าใช้จ่าย การทำ performance และ utilize resource ได้ดีระดับนึง (เพราะ core คือ nginx) บวกกับ feature ที่ไปต่อ in-memory DB อย่าง <strong>redis </strong>หรือ <strong>memcache </strong>ก็เป็นไอเดียให้สามารถต่อยอดในการเพิ่มความปลอดภัยเพิ่มขึ้นโดยการทำ session storage ก็ดูจะเป็นแนวทางที่เหล่า developer จะได้ลองนำไปพัฒนาและต่อยอดใน project ของท่านเอง</p><blockquote>ทั้งนี้การ demo code ให้ดูอาจจะไม่ได้ครบถ้วนเรื่อง detail setup หรือ security principle ต่างๆ เพราะผู้เขียนต้องการแค่จะ guide และ share ประสบการณ์ที่ผู้เขียนได้เคย design ระบบนี้ไว้ และค่อนข้างใช้งานได้ดีบน production ครับ</blockquote><h3>บทความที่เกี่ยวข้อง</h3><p><a href="https://j-wor.medium.com/%E0%B8%A1%E0%B8%B2%E0%B8%97%E0%B8%B3api-gateway-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-openresty-%E0%B8%81%E0%B8%B1%E0%B8%99%E0%B9%80%E0%B8%96%E0%B8%AD%E0%B8%B0-%E0%B8%95%E0%B8%AD%E0%B8%99%E0%B8%97%E0%B8%B5%E0%B9%88-1-ffc8f7b97381">มาทำAPI Gateway ด้วย OpenResty กันเถอะ</a></p><h3>Resources</h3><ul><li><strong><em>JWT</em></strong>: <a href="https://jwt.io/">https://jwt.io</a></li><li><strong><em>Openresty</em></strong>: <a href="https://github.com/openresty/docker-openresty">https://github.com/openresty/docker-openresty</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3d7547e95ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ทำ Automate API testing ด้วย postman]]></title>
            <link>https://j-wor.medium.com/%E0%B8%97%E0%B8%B3-automate-api-testing-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-postman-fda1af08c990?source=rss-874ea6838138------2</link>
            <guid isPermaLink="false">https://medium.com/p/fda1af08c990</guid>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[automated-testing]]></category>
            <category><![CDATA[api-testing]]></category>
            <category><![CDATA[newman]]></category>
            <category><![CDATA[postman]]></category>
            <dc:creator><![CDATA[Worawut.J(worwae)]]></dc:creator>
            <pubDate>Tue, 19 Jan 2021 10:45:38 GMT</pubDate>
            <atom:updated>2021-01-22T05:58:30.670Z</atom:updated>
            <content:encoded><![CDATA[<p>สาย API testing มาเขียน CI test ด้วย newman กันเถอะ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*2iDgs0WgjROx858jS8VxZQ.png" /></figure><p>สำหรับคนที่ยังไม่รู้ postman ที่เราใช้กัน มันสามารถเขียน test และ run ด้วย CLI ได้ด้วย library javaScript ที่ชื่อว่า <a href="https://www.npmjs.com/package/newman">newman</a></p><p><em>บทความนี้มีความ advance อยู่บ้างเล็กน้อย ใครไม่เคยใช้ CLI (Command-line user interface) อาจจะงงนิดๆ ถึงมึนไปเลย ฮา..ฮา..</em></p><h3>ลงมือ…</h3><h4>เรามาสร้าง sample test ง่ายๆ บน postman กันก่อน</h4><ol><li>ที่ collection request ให้กดที่ tab <strong>Tests</strong></li><li>ใส่ script test ลงไป กดลอกตัวอย่างด้านขวามาก็ได้</li></ol><pre>pm.test(&quot;Status code is 200&quot;, <em>function</em> () {<br>   pm.response.to.have.status(200);<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c4QiAAMfFkuJICVbDYmK4A.png" /><figcaption>Status code is 200</figcaption></figure><h4>กด test แล้วดูผลลัพท์ “ง่ายมะ”</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*cdHv1PKfT6hjYfCBF7mI_w.png" /><figcaption>PASS | Status code is 200</figcaption></figure><h4>ได้ test case เรียบร้อยแล้ว step ต่อไปมาทำให้ test แบบ automate ต่อดีกว่า</h4><ol><li>install newman ก่อนนะ</li></ol><pre>$ npm install -g newman</pre><p>2. ไป share collection ที่เรา setup test ไว้มาก่อน (เลือก Get public link)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*4ZboeZmaGa3FYZRj84TabQ.png" /><figcaption>หลังจากกด Share ให้เลือก Get public link</figcaption></figure><p>3. ทดลองสั่ง run ได้เลยตามด้านล่าง</p><pre>$ newman run <a href="https://www.getpostman.com/collections/631643-f695cab7-6878-eb55-7943-ad88e1ccfd65-JsLv">https://www.getpostman.com/collections/x</a>xxxxxxx</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*H51EzVpCopQhXpUR3q3U3w.png" /><figcaption>ตัวอย่างเป็น sample-request ที่เขียน test ไว้</figcaption></figure><h4>มาต่อกับเครื่องมือช่วยทำ CI อย่าง jenkins ไว้ดู test report งามๆ ก็ได้</h4><pre>$ newman run <a href="https://www.getpostman.com/collections/xxxxxxxx">https://www.getpostman.com/collections/xxxxxxxx</a> — reporters cli,html,junit — reporter-junit-export POSTMAN-HERO.xml — reporter-html-export POSTMAN-HERO.html -x</pre><ol><li>create <strong>Freestyle project</strong> บน jenkins</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/963/1*4quJTpia3CF5XmAI6Mhj-Q.png" /><figcaption>create freestyle project item</figcaption></figure><p>2. ใส่ newman script ใน build step</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/923/1*b7ZN_pdqjhJNUXiVIQCapA.png" /><figcaption>command-line user interface</figcaption></figure><p>3. setup Junit และ publish html report</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*dQw5jj4M65GojypAZ7Xmwg.png" /><figcaption>Junit และ publish html report</figcaption></figure><p>4. ลองกด <strong>Build</strong> ดู ถ้า <em>success </em>เราจะได้ report dashboard มาแสดงบน jenkins ได้เลย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*NWvEqlNqYWTIYk1KaQhlhQ.png" /><figcaption>Junit report</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SfVKs1c1U-fsd6Yx-3kpRQ.png" /><figcaption>HTML Report</figcaption></figure><p><em>ทั้งนี้เราสามารถจะตั้ง schedule หรือจะเป็น git trigger กันได้เองตามใจชอบ เท่านี้ก็ได้ </em><strong><em>automate API testing</em></strong><em> ไว้ใช้งานชิลล์ๆ ละ</em></p><h4>สรุป</h4><p>postman + newman เป็นเครื่องมือที่มี feature น่าสนใจและเราใช้ประโยชน์กับมันได้เยอะมาก รวมทั้งยังช่วยลดงานซ้ำซ้อนและงาน manual ได้พอสมควร หวังว่าจะมีประโยชน์ครับ</p><h3><strong>บทความที่เกี่ยวข้อง</strong></h3><p><a href="https://j-wor.medium.com/%E0%B9%83%E0%B8%8A%E0%B9%89-postman-%E0%B8%A2%E0%B8%B1%E0%B8%87%E0%B9%84%E0%B8%87%E0%B9%83%E0%B8%AB%E0%B9%89%E0%B8%94%E0%B8%B9%E0%B9%82%E0%B8%9B%E0%B8%A3-3e47c1e4326">ใช้ postman ยังไงให้ดูโปร</a></p><h3>Resources</h3><ul><li><strong><em>Newman </em></strong>: <a href="https://www.npmjs.com/package/newman">https://www.npmjs.com/package/newman</a></li><li><strong><em>Postman </em></strong>: <a href="https://learning.postman.com/">https://learning.postman.com</a></li><li><strong><em>Jenkins </em></strong>: <a href="https://www.jenkins.io/doc/">https://www.jenkins.io/doc</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fda1af08c990" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ใช้ postman ยังไงให้ดูโปร]]></title>
            <link>https://j-wor.medium.com/%E0%B9%83%E0%B8%8A%E0%B9%89-postman-%E0%B8%A2%E0%B8%B1%E0%B8%87%E0%B9%84%E0%B8%87%E0%B9%83%E0%B8%AB%E0%B9%89%E0%B8%94%E0%B8%B9%E0%B9%82%E0%B8%9B%E0%B8%A3-3e47c1e4326?source=rss-874ea6838138------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e47c1e4326</guid>
            <category><![CDATA[postman]]></category>
            <category><![CDATA[back-end-developer]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Worawut.J(worwae)]]></dc:creator>
            <pubDate>Mon, 20 Jul 2020 10:06:19 GMT</pubDate>
            <atom:updated>2020-07-20T10:06:19.940Z</atom:updated>
            <content:encoded><![CDATA[<p>คนสาย mobile application , web API จะต้องคุ้นเคยกับ tool สำหรับใช้ยิง test API หนึ่งในนั้นก็คือ <a href="https://www.postman.com/">postman </a>นั่นเอง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U2DBNEXuvrHvPzCyNtvElw.png" /><figcaption><a href="https://www.postman.com/">https://www.postman.com</a></figcaption></figure><p>สำหรับการใช้งานเบื้องต้น ก็ไม่ได้ยากเย็นอะไรคงจะทำเป็นกันแล้ว แต่เราจะมาสอนใช้งานให้ดู professional กัน</p><h4>เริ่มเลยเราต้องมารู้จักสิ่งนี้ก่อน</h4><blockquote><strong>Variable หลักๆ จะมี 2 แบบคือ</strong></blockquote><ul><li>Global variable</li><li>Environment variable</li></ul><p>ลองมาสร้างกัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*lfJFKASPcR8hAu0zPS7n1w.png" /></figure><ol><li>ให้กดตรงฟันเฟืองขวามือ</li><li>Add environments กัน<br><strong>STAGING<br></strong>url:https://api.staging.example.com</li><li>กด Add ได้เลย (ถ้าอยากมีมากกว่านี้ duplicate เอานะ)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*hugD6sec2TSxLJf-WAmmzQ.png" /><figcaption>ตัวอย่างเลยคือจะตั้งชื่อเป็น STAGING</figcaption></figure><blockquote>Collection จะสามารถเก็บเป็น folder ของแต่ละชุด api ได้</blockquote><p>สร้างเลยสิ รออะไร</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*Q0yokIWAx7Md5_47jHfkmA.png" /></figure><ol><li>Create request ก่อน</li><li>Create and save to collection โลด</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*9-PPCXm2jyj3IYt2zTi9_g.png" /><figcaption>hello API request</figcaption></figure><blockquote>โอเคละ ทีนี้เราก็ได้ Collectionและ <strong>environment </strong>มาพร้อมใช้งานแบบไม่ต้องแยก request <strong>STAGING</strong>, <strong>PRODUCTION </strong>ออกจากกันละ</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l67ZSm2E4OOeUALEdRYmcw.png" /><figcaption>environment (STAGING, PRODUCTION)</figcaption></figure><p>ยกตัวอย่างจาก api ที่ทีม backend กำลังพัฒนาอยู่ ก็จะต้องมีอย่างน้อย 2 environment (STAGING, PRODUCTION)</p><blockquote>พอจะ get แล้วใช่มะ ทีนี้เราก็มี variable ไว้ใช้งานได้ละ</blockquote><h4><strong>แถม</strong> postman เค้ามีตัวอย่าง http client ให้เรา copy เอาไปใช้งานได้เลยนะเออ แค่กดตรง Code</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*-rSbmrkh2X6ATJHCZFXcCA.png" /><figcaption>Request API ข้างๆ Cookies</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*It4JWcma4v17CH-N0vMX_Q.png" /><figcaption>ได้ออกมาเป็น code เลย เจ๋งโคตร</figcaption></figure><p>สรุป postman เป็นเครื่องมือที่ developer ต้องมีติดเครื่องใช้งานกัน แต่จะดีกว่ามั้ยที่เราจะใช้ความสามารถของมันให้เต็มที่ เพื่อสร้าง productivity ให้กับงานของเรา</p><p>รอบหน้ามาเขียน automate test with postman กัน</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e47c1e4326" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[มาทำAPI Gateway ด้วย OpenResty กันเถอะ]]></title>
            <link>https://j-wor.medium.com/%E0%B8%A1%E0%B8%B2%E0%B8%97%E0%B8%B3api-gateway-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-openresty-%E0%B8%81%E0%B8%B1%E0%B8%99%E0%B9%80%E0%B8%96%E0%B8%AD%E0%B8%B0-%E0%B8%95%E0%B8%AD%E0%B8%99%E0%B8%97%E0%B8%B5%E0%B9%88-1-ffc8f7b97381?source=rss-874ea6838138------2</link>
            <guid isPermaLink="false">https://medium.com/p/ffc8f7b97381</guid>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[openresty]]></category>
            <category><![CDATA[lua]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Worawut.J(worwae)]]></dc:creator>
            <pubDate>Tue, 14 Jul 2020 04:01:53 GMT</pubDate>
            <atom:updated>2020-07-14T05:22:50.909Z</atom:updated>
            <content:encoded><![CDATA[<h3>เกริ่นก่อน</h3><p>ออกตัวว่าเพิ่งจะได้เริ่มเขียน blog เป็นครั้งแรก หากไม่เข้าใจ(เขียนอะไรวะ) ขออภัยไว้ก่อนเลย</p><p>เมื่อ 2–3 ปีก่อน ได้รับ assign ให้ transform app ๆ นึงเป็น micro service (มันคืออะไรวะ ??) เราก็เลยไปตามหาว่า มันควรจะเริ่มจากอะไร และส่วนสำคัญที่ทำให้มัน transform ได้อย่างคล่องตัวนั่นคือ NGINX</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*ID2ZPL87qn7PQJdYH3Wcnw.png" /><figcaption><a href="https://www.nginx.com/blog/building-microservices-using-an-api-gateway/">https://www.nginx.com/blog/building-microservices-using-an-api-gateway/</a></figcaption></figure><p>แต่ทว่า NGINX ธรรมดามันเหมือนจะต้องเริ่มต้นจากศุนย์ (คิดไปเอง ฮ่าๆ) ส่วน Kong API Gateway มันก็ดูยิ่งใหญ่เกินไป เลยไปหาดูซิว่า NGINX ตัวไหนมันสามารถทำหน้าที่ API Gateway ได้พอใกล้เคียงกับ Kong คำตอบนั้นคือ “<a href="https://openresty.org/"><strong>OpenResty</strong></a>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*rDhnt2yjtaYBLclbzcFmoA.png" /><figcaption><a href="https://openresty.org/en/">https://openresty.org/en/</a></figcaption></figure><h3>เริ่มต้น</h3><p>เราลองเอา OpenResty มา configure ดูเพื่อ run เป็น web server ปรากฎว่า “มันง่ายแฮะ” ลองมาดู configure</p><pre>http { <br>  server{ <br>    listen 8080; <br>    location / {<br>      default_type text/html;<br>      content_by_lua_block {<br>        local foo = ngx.var.arg_bar<br>        ngx.log(ngx.DEBUG, &#39;get foo =&gt; &#39;, foo)<br>      }<br>    }<br>  }<br>}</pre><p>แบบว่ามัน pre-process ให้ได้ด้วยวุ้ย(เขียนด้วยภาษา <a href="http://www.lua.org/">Lua</a>) เริ่มสนุก.. เราเลยไป deep down ต่อว่ามันทำอะไรได้บ้าง ปรากฎว่ามันมี library ให้เราได้เล่นหลายตัวเลยอย่างเช่น memcache, redis แบบนี้เราได้ idea ละ จะเอา OpenResty ไปต่อยอดเป็น API Gateway ได้ยังไง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xBKsI8nUIULdN06Mfi0Vag.png" /><figcaption><a href="https://openresty.org/en/components.html">https://openresty.org/en/components.html</a></figcaption></figure><h3>สรุป</h3><p><strong>OpenResty </strong>เป็นเครื่องมือที่น่าจะเข้ามาตอบโจทย์เราได้มากทั้งเรื่องของความสามารถพื้นฐานและ ความพร้อมใช้งานของ library สำหรับการเลือก opensource ซักตัวมาทำเป็น API Gateway ให้ micro service ของเรา</p><p>ภาคต่อเราจะลองมา connect กับ redis กัน TBC</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ffc8f7b97381" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>