<?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 Nuttapon Pinitpaitoon on Medium]]></title>
        <description><![CDATA[Stories by Nuttapon Pinitpaitoon on Medium]]></description>
        <link>https://medium.com/@nuttaponpinitpaitoon?source=rss-9c846f5b6629------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*gGVy6Oje3ymu6zGo</url>
            <title>Stories by Nuttapon Pinitpaitoon on Medium</title>
            <link>https://medium.com/@nuttaponpinitpaitoon?source=rss-9c846f5b6629------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 20:32:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nuttaponpinitpaitoon/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[Windows Clipboard History]]></title>
            <link>https://medium.com/blog-blog/windows-clipboard-history-d33a758ad0d9?source=rss-9c846f5b6629------2</link>
            <guid isPermaLink="false">https://medium.com/p/d33a758ad0d9</guid>
            <category><![CDATA[windows-10]]></category>
            <category><![CDATA[clipboard]]></category>
            <dc:creator><![CDATA[Nuttapon Pinitpaitoon]]></dc:creator>
            <pubDate>Wed, 15 Dec 2021 03:24:37 GMT</pubDate>
            <atom:updated>2021-12-15T03:24:37.379Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ubsz6GS8HjMqXtBt.jpg" /><figcaption><a href="https://www.dignited.com/58250/windows-10-clipboard-history/">https://www.dignited.com/58250/windows-10-clipboard-history/</a></figcaption></figure><h3>Windows Clipboard History</h3><p>แนะนำ Feature Clipboard ของ Windows 10 ซึ่งมีมาตั้งแต่ Version 1809 (October 2018 Update) แล้วนะครับ ถ้าใช้ version สูงกว่านั้นก็ใช้ได้เลยครับ</p><h3>วิธีการเปิดใช้งาน</h3><p>กด windows + v ขึ้นมาแล้ว ถ้ายังไม่เคยเปิดใช้งานระบบจะขึ้น dialog มาให้เรา Turn On ครับ ก็กด Turn On กันไป</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/239/1*VYY4-zIgtMJCM6WbeDMskQ.png" /></figure><p>เมื่อเปิดใช้งานแล้วระบบจะแสดง history ที่เราเคย copy มา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/293/1*MJJ-R93wNGTPR3QjWYR-IA.png" /></figure><p>เราสามารถเลือก Past Clipboard ได้ตามต้องการเลยครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/291/1*R0lBMv7L2IayRGV1FN-kTQ.png" /></figure><p>นอกจากนี้เรายังสามารถ Pin สิ่งที่ Copy ไว้ให้อยู่ตลอดไปแม้ว่าจะ Clear All แล้วก็ตามนะครับ</p><h3>ข้อจำกัด</h3><ul><li>Clipboard สามารถจัดเก็บสูงสุด 25 รายการล่าสุด</li><li>ขนาดของ Clipboard ไม่เกิน 4 MB</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d33a758ad0d9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/blog-blog/windows-clipboard-history-d33a758ad0d9">Windows Clipboard History</a> was originally published in <a href="https://medium.com/blog-blog">blog blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[บันทึกการ Expand disk ใน centos 7]]></title>
            <link>https://medium.com/blog-blog/%E0%B8%9A%E0%B8%B1%E0%B8%99%E0%B8%97%E0%B8%B6%E0%B8%81%E0%B8%81%E0%B8%B2%E0%B8%A3-expand-disk-%E0%B9%83%E0%B8%99-centos-7-f44ab867a731?source=rss-9c846f5b6629------2</link>
            <guid isPermaLink="false">https://medium.com/p/f44ab867a731</guid>
            <category><![CDATA[expand]]></category>
            <category><![CDATA[centos7]]></category>
            <category><![CDATA[lvm]]></category>
            <dc:creator><![CDATA[Nuttapon Pinitpaitoon]]></dc:creator>
            <pubDate>Thu, 09 Dec 2021 05:08:10 GMT</pubDate>
            <atom:updated>2021-12-09T10:40:02.944Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*87cvguyM6JoJwkSX8vEQCA.png" /><figcaption><a href="http://celtic-id.com/business-ready-expand/">http://celtic-id.com/business-ready-expand/</a></figcaption></figure><p>ทดสอบสร้าง vm ของ centos7 ใน virtual box โดยกำหนด storage ให้มีขนาด 10 GB ให้ โดยกำหนด partition ตอนติดตั้ง ตามที่ centos 7 กำหนดให้อัตโนมัติ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YN8X2ZEtCSs2JCeMblz1Ig.png" /></figure><p>เมื่อติดตั้ง os เสร็จลองตรวจดู mount point ต่างๆ ได้ดังนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*nHT7hwRdjoHu8DJUhyU3iQ.png" /></figure><p>จากนั้นลองเพิ่ม size ของ disk โดยปิด vm และเพิ่มเนื้อที่ผ่านทาง virtual media manager</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*kjQZu0rAjiTpi8_5Q1AQVQ.png" /></figure><p>เมื่อ start vm กลับเข้ามาตรวจสอบเนื้อที่อีกครั้ง จะพบว่า mount point ต่างๆ ยังเห็นเนื้อที่เท่าเดิม ซึ่งถ้าตรวจสอบผ่าน parted แล้วจะเห็นความแตกต่างตรง disk : /dev/sda จากคำสั่ง parted -p ที่ได้เนื้อที่เพิ่มขึ้นมาตามที่เราขยายเอาไว้ (20 GB)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*qNzZoChX7APdTAGbiYflUg.png" /></figure><p>เริ่มการขยาย partition โดยเริ่มต้นจากเราต้อง disable swap ก่อน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*iguHWDqMCASHiiH_uuWcBQ.png" /></figure><p>แล้วเข้าไปแก้ไข file /etc/fstab เพื่อปิดการ mount swap ไว้ก่อน (ค่อยมาเปิดใช้งานตอนหลัง)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*KEGnPXMBOqXsnKVOzcDR_Q.png" /></figure><p>จากนั้นเข้ามาจัดการ partition ผ่าน command parted</p><p>(parted) p → ดูว่ามี partition แบบไหนอยู่บ้าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*kwucDkN3WP_OAITFlyEtew.png" /></figure><p>จะเห็นว่าเรามี 2 partition คือ 1 (boot) , 2 (lvm) ซึ่งเราจะมาขยาย 2 (lvm) ให้มีขนาดใหญ่ขึ้น (เดิมมันจะ end ที่ 10.7 GB)</p><p>ต่อมาเราควรจะเปลี่ยนหน่วยของ parted ให้แสดงเป็น sector แทนเพื่อจะได้กำหนดจุดเริ่มต้นและสิ้นสุดได้อย่างถูกต้อง ป้องกันความผิดพลาด</p><p>(parted) u</p><p>(parted) s</p><p>(parted) p</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*owyqjYTgRJHfTWI8bs_Rtg.png" /></figure><p>ระบบจะแสดงเป็น sector ของ partition เริ่มต้นและสิ้นสุดแทน</p><p>จากนั้นเราจะมาปรับขยาย number(2) กันเริ่มจาก ลบ partition (2)</p><p>(parted) rm 2</p><p>(parted) Ignore</p><p>(parted) p</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*JsV9ZWKmtAjFnFclHxNRXA.png" /></figure><p>เริ่มสร้าง partition ใหม่</p><p>(parted) mkpart</p><p>file type? xfs</p><p>start? ใส่ค่า start จาก number 2 เดิมมาใส่ ในที่นี้คือ 2099200s</p><p>end? ใส่ค่า sector สุดท้าย ดูจาก Disk /dev/sda: แต่ให้ลดลงมาเล็กน้อย ในตัวอย่างคือ 41900000s</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*sLS6M8HHJoLIW5EE_g6TVw.png" /></figure><p>จากนั้นขยายผ่าน command pvresize ด้วย pvresize /dev/sda2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*D4TjiuTSzPQSOEBiRqzOQg.png" /></figure><p>หลังคำสั่ง pvresize แล้วจะได้ vsize และ vfree เพิ่มขึ้นมาแล้ว</p><p>จากนั้นลอง vgdisplay และให้จำค่า Free PE/Size และจำค่า Free PE เอาไว้ 2555</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*73KwgqoVh57JVLmTROL4Lw.png" /></figure><p>ตรวจสอบ lv ผ่าน command lvdisplay</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*JvoUXW-pHUi5tzDSPuFRyg.png" /></figure><p>ทดสอบเพิ่ม lv ตาม free PE ของ vg</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*3JZwL3Rg4KsHB8OwiCIVpQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*4JULQ1AJey1q23FtlWlzZA.png" /></figure><p>จากนั้นต้องมาทำ resize file system ผ่าน command xfs_growfs</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*l5RinqzSGnj4H8p51ryB4g.png" /></figure><p>เมื่อตรวจสอบ mount point อีกครั้งจะพบว่าเนื้อที่เพิ่มขึ้นมา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*Xs5n8Oc2S03055NgqCQuwQ.png" /></figure><p>เสร็จแล้วก็ไปเปิด swap กลับขั้นมาใช้งาน uncommnet /etc/fstab จากนั้น restart</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f44ab867a731" width="1" height="1" alt=""><hr><p><a href="https://medium.com/blog-blog/%E0%B8%9A%E0%B8%B1%E0%B8%99%E0%B8%97%E0%B8%B6%E0%B8%81%E0%B8%81%E0%B8%B2%E0%B8%A3-expand-disk-%E0%B9%83%E0%B8%99-centos-7-f44ab867a731">บันทึกการ Expand disk ใน centos 7</a> was originally published in <a href="https://medium.com/blog-blog">blog blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Traefik Proxy #1]]></title>
            <link>https://medium.com/blog-blog/traefik-proxy-1-2296a654e7e3?source=rss-9c846f5b6629------2</link>
            <guid isPermaLink="false">https://medium.com/p/2296a654e7e3</guid>
            <category><![CDATA[reverse-proxy]]></category>
            <category><![CDATA[traefik]]></category>
            <dc:creator><![CDATA[Nuttapon Pinitpaitoon]]></dc:creator>
            <pubDate>Sun, 10 Jan 2021 07:43:23 GMT</pubDate>
            <atom:updated>2021-01-10T07:43:23.643Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*HeZSNXFyAQlbhd7PvcxkqA.png" /><figcaption><a href="https://doc.traefik.io/traefik/assets/img/traefik-architecture.png">https://doc.traefik.io/traefik/assets/img/traefik-architecture.png</a></figcaption></figure><p>Traefik เป็น open-source Edge Rounter ครับไว้ใช้สำหรับจัดการการเข้าถึง service ต่างๆ ของระบบเรา ซึ่งมันมี feature มากมายทำให้การใช้งานนั้นสะดวกขึ้นครับ</p><p>โดย Traefik นั้นจะมี Concept หลังๆ 2 อย่างครับคือ</p><ul><li>Edge Router ทำตัวเป็นประตูของ Platform ครับคอยจัดการทางเข้าของ Request ต่างๆ ที่จะเข้ามาในระบบ</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*kb26DFJ1rzAH_qv3qz84Ng.png" /><figcaption><a href="https://doc.traefik.io/traefik/assets/img/traefik-concepts-1.png">https://doc.traefik.io/traefik/assets/img/traefik-concepts-1.png</a></figcaption></figure><ul><li>Auto Service Discovery สมัยก่อนต้องใช้การกำหนดค่า config ต่างๆมากมายเพื่อบอกว่า service นั้นอยู่ที่ไหน แต่ว่าใน traefik นั้นจะมีเทคนิคของ provider เข้ามาเพื่อคอยจัดการหาที่อยู่ของ service ต่างๆ และจัดการเรื่อง rules ต่างๆ แบบ real time ทำให้สะดวกในการใช้งาน</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*JLg9CoT0Pt-XBQIsZXD1Sw.png" /><figcaption><a href="https://doc.traefik.io/traefik/assets/img/traefik-concepts-2.png">https://doc.traefik.io/traefik/assets/img/traefik-concepts-2.png</a></figcaption></figure><p>อาจจะยังงงๆและไม่เห็นภาพมาลองเล่นกันดีกว่า</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0f0827af1a9c11a281e3b4fa6f6dcea/href">https://medium.com/media/c0f0827af1a9c11a281e3b4fa6f6dcea/href</a></iframe><p>จากตัวอย่างจะเป็นการสร้าง service ขึ้นมา 2 ตัวนะครับ อันแรกคือ traefik และอีกอันคือ whoami service โดยจะให้ traefik เป็น reverse-proxy ของ whoami อีกที</p><p>public port ที่ compose file นี้เปิดคือ 80 และ 8080 โดย 80 นั้นจะใช้เป็น Entrypoint ของ Traefik และ 8080 จะใช้เป็น UI Dashboard ของ Traefik ครับ</p><p>ลองทดสอบรัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*PODd4oJ7zSB-ksmMMZ3CWQ.png" /></figure><p>ถ้าไม่ error อะไรก็ทดลองเข้าไปดูที่ UI Dashboard <a href="http://localhost:8080/dashboard/#/">http://localhost:8080/dashboard/#/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y5VMMx5e_daU2Ecnlbq1Pg.png" /></figure><p>ลองเรียกใช้งานไปที่ entrypoint whoami (80) ครับ <a href="http://localhost/whoami">http://localhost/whoami</a> (ต้องใส่ /whoami ด้วยนะครับเพราะในตัวอย่างนี้ config ระบุไว้ว่าจะ rounting ด้วย Rule แบบ PathPrefix /whoami)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MBsZvrAw6DWjb9sY3BwMUg.png" /></figure><p>ทีนี้กลับมาอธิบาย config ใน compose file กัน (การกำหนดค่าใน provider docker นั้นสามารถกำหนดค่าผ่านทาง label ใน compose file ได้เลย)</p><p>เริ่มจากใน traefik service กันก่อน</p><ul><li>providers.docker=true เปิดการใช้งาน provider docker</li><li>providers.docker.exposedbydefault=false กำหนดค่าให้ไม่ต้องเปิด service แบบอัตโนมัติ (ค่า default จะเปิดอัตโนมัติ)</li><li>entrypoints.whoami.address=:80 เป็น entrypoint ที่ point 80 โดยใช้ชื่อว่า whoami อันนี้แล้วแต่จะตั้งกันนะครับแต่ในตัวอย่างจะกำหนดเป็น whoami</li></ul><p><strong>หมายเหตุ</strong> อย่าลืม mount docker.sock เข้าไปใน traefik service ด้วยนะครับ (volumes: — /var/run/docker.sock:/var/run/docker.sock:ro)</p><p>ต่อมาไปดูกันที่ whoami service</p><ul><li>traefik.enable=true เปิดการใช้งาน traefik ครับเนื่องจากเราข้างบนเรากำหนดค่า exposedbydefault เป็น false เอาไว้ก็เลยต้องมาตั้งเปิดกันที่ระดับ service เองครับ</li><li>traefik.http.routers.whoami.entrypoints=whoami กำหนดค่า routers ของ service นี้เข้ากับ entrypoints ชื่อ whoami</li><li>traefik.http.routers.whoami.rule=PathPrefix(`/whoami`) กำหนด rule ของการ routing แบบ PathPrefix ด้วยคำว่า whoami</li></ul><p>มาลองดูการทำ auto discovery service กันดูเริ่มต้นจากให้ลองเข้ามาที่ Dashboard ของ Traefik ครับแล้วไปที่ http service จะมีชื่อ whoami-1-basic@docker คลิกเข้าไปดูรายละเอียด</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*SSh_gCJEq3wfH07pGAt65g.png" /></figure><p>ดูที่ Server จะเห็นว่ามีอยู่ 1 อัน</p><p>เรามาลอง scale service นี้กันดูครับด้วยคำสั่ง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*_SvLlOGtUw9NHQ_XrQjyaw.png" /></figure><p>จะเห็นว่าเรามี container whoami เพิ่มขึ้นมาเป็น 3 อัน จากนั้นลองกลับไปที่ traefik dashboard ครับแล้ว refresh ดูจะพบว่ามี server เพิ่มเป็น 3 อันตามครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/1*GC84KF_lQO8tnabBKy4t4g.png" /></figure><p>ทดสอบการยิงไปที่ whoami ใหม่อีกครั้ง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*H2J-gbBu4qR3pO7Ubyp1Cg.png" /></figure><p>สังเกตุตรง IP จะเปลี่ยนไปเรื่อยแบบ round robin (default ของ service จะเป็น loadbalance แบบ round robin)</p><p>ส่วนตัวคิดว่าการกำหนดค่าผ่านทาง provider docker นั้นค่อนข้างจะสะดวกมากครับโดยสามารถทำผ่าน lable ของ docker-compose ไปได้เลย ไม่ต้องมี config แยกมาให้วุ่นวายเหมือน nginx ที่ต้อง mount config ออกมาปรับแก้ไข</p><p>และในส่วนของ auto discovery service นั้นก็ทำให้การ scale นั้นสะดวกขึ้น ไม่ต้องมีค่อย restart/reload config อะไรเลย อีกทั้งมีหน้า dashboard ให้ใช้งานได้สะดวกขึ้นครับ</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2296a654e7e3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/blog-blog/traefik-proxy-1-2296a654e7e3">Traefik Proxy #1</a> was originally published in <a href="https://medium.com/blog-blog">blog blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java 10 Local-Variable Type Inference]]></title>
            <link>https://medium.com/blog-blog/java-10-local-variable-type-inference-a49e6cf9a521?source=rss-9c846f5b6629------2</link>
            <guid isPermaLink="false">https://medium.com/p/a49e6cf9a521</guid>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Nuttapon Pinitpaitoon]]></dc:creator>
            <pubDate>Wed, 16 Dec 2020 12:52:26 GMT</pubDate>
            <atom:updated>2020-12-17T02:58:13.761Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/321/1*_HJPzh4khWXV3OXOH9njAw.png" /><figcaption><a href="https://dzone.com/articles/109-new-features-in-jdk-10">https://dzone.com/articles/109-new-features-in-jdk-10</a></figcaption></figure><h3>Local-Variable Type Inference</h3><p>มันเป็น feature ใหม่ใน jdk 10 ทำให้เราสามารถประกาศค่า local variable ด้วยคำว่า var ไว้ก่อนแล้วมันจะรู้ type เองตอน compile ครับ ทำให้การเขียน code สั้นลงและอ่านได้ง่ายขึ้นครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*xo_IlTQA2fO0bg24492EFw.png" /></figure><h3>ใช้ได้กับ</h3><ul><li>local variables with initializers (ตัวแปร Local พร้อมด้วยการกำหนดค่าเริ่มต้น)</li><li>indexes in for each loops (ตัวแปร index ใน for loop)</li><li>locals in for loops (ตัวแปร local ใน for loop)</li></ul><h3>ใช้ไม่ได้กับ</h3><ul><li>method formals (ตัวแปร parameter ของ method)</li><li>constructor formals (ตัวแปร parameter ของ constructor)</li><li>method return types (return ค่าของ method)</li><li>fields (ตัวแปรของ class)</li><li>catch formals (ตัวแปร parameter ของ catch)</li></ul><p>ref.</p><ul><li><a href="https://blog.idrsolutions.com/2018/04/java-10-local-variable-type-inference-explained-in-5-minutes/">Java 10 Local-Variable Type Inference Explained in 5 Minutes</a></li><li><a href="https://nipafx.dev/java-10-var-type-inference/">First Contact With &#39;var&#39; In Java 10 - nipafx</a></li><li><a href="https://dzone.com/articles/109-new-features-in-jdk-10">109 New Features in JDK 10 - DZone Java</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a49e6cf9a521" width="1" height="1" alt=""><hr><p><a href="https://medium.com/blog-blog/java-10-local-variable-type-inference-a49e6cf9a521">Java 10 Local-Variable Type Inference</a> was originally published in <a href="https://medium.com/blog-blog">blog blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OWASP API 2019 : API-4 Lack of Resources & Rate Limiting]]></title>
            <link>https://medium.com/blog-blog/owasp-api-2019-api-4-lack-of-resources-rate-limiting-6a49f00334ae?source=rss-9c846f5b6629------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a49f00334ae</guid>
            <category><![CDATA[owasp-api-2019]]></category>
            <category><![CDATA[owasp-api]]></category>
            <dc:creator><![CDATA[Nuttapon Pinitpaitoon]]></dc:creator>
            <pubDate>Tue, 15 Dec 2020 14:48:57 GMT</pubDate>
            <atom:updated>2020-12-17T02:52:38.648Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*THcJsy-kr0SJmL8M.png" /><figcaption><a href="https://42crunch.com/owasp-api-security-top-10/">https://42crunch.com/owasp-api-security-top-10/</a></figcaption></figure><h3>OWASP API 2019 : API-4 Lack of Resources &amp; Rate Limiting</h3><p>OWASP API ข้อนี้ก็จะเป็นในเรื่องของการที่ API ไม่ได้จำกัดการ request ของ client/user ซึ่งนอกจะทำให้มีผลกระทบกับ server performance และทำให้เกิด Denial of Service (Dos) แล้วยังอาจเป็นช่องทางให้เกิดการโจมตีแบบ brute force ได้อีกด้วย</p><p>ทุก API ที่ request เข้ามาก็จะมีการใช้ทรัพยากรต่างๆของ server นะ เช่น network, CPU, memory และ storage ซึ่งแต่ละ request นั้นก็จะมีการใช้ตามแต่ user input และก็ตาม business logic นั้นๆ แตกต่างกันไป ซึ่งถ้าพิจารณาแล้วกรณีที่ request มาจากหลาย API มันก็จะเหมือนจะเป็นการแย่ง resource กันไป ซึ่งความเสี่ยงที่เกิดขึ้นก็จะมาจากการที่ไม่มีการกำหนดค่า limit หรือตั้งค่าไม่เหมาะสมนั้นเอง</p><p>ตัวอย่างของค่าที่ควรจะพิจารณา</p><ul><li>Execution timeouts</li><li>Max allocable memory</li><li>Number of file descriptors</li><li>Number of processes</li><li>Request payload size (e.g., uploads)</li><li>Number of requests per client/resource</li><li>Number of records per page to return in a single request response</li></ul><p>ตัวอย่างการโจมตี</p><ul><li>ผู้โจมตี upload ภาพโดยผ่าน POST ส่งไปที่ /api/v1/images เมื่อ upload ไปแล้ว API จะสร้างภาพ thumbnails ขนาดต่างๆ ออกมา ซึ่งแต่ละครั้งที่ upload เข้ามา api ต้องใช้ memory ในการสร้าง thumbnails ขนาดต่างๆ ซึ่งอาจทำให้ API ไม่ตอบสนองได้</li><li>เรามีหน้าจอ list user ของระบบออกมาโดยตั้ง limit ไว้ที่ 200 per page ผ่านทาง API ก็จะมีลักษณะแบบนี้ /api/users?page=1&amp;size=200 แต่ผู้โจมตีจะเปลี่ยนค่าของ size ให้เป็น 200,000 ซึ่งจะส่งผลกระทบกับ performance ของ database ทำให้ api ไม่ตอบสนองและยังส่งผลกระทบกับ request ของ client อื่นๆ อีกด้วย (DoS) อีกทั้งอาจะทำให้เกิด integer overflow หรือ buffer overflow ได้อีกด้วย</li></ul><p>การป้องกัน</p><ul><li>Docker ทำได้ง่ายๆ โดยตั้งค่า limit memory, CPU, number of restarts, file descriptors and processes</li><li>Implement limit จำนวน request ที่ client สามารถเรียก API ได้ต่อ 1 ช่วงระยะเวลาที่กำหนด เช่น 10/sec</li><li>แจ้งเตือน client เมื่อชน limit และบอกถึงจำนวน limit และระยะเวลาที่ limit จะถูก reset ไป (ต้องรออีกนานเท่าไร)</li><li>เพิ่มการตรวจสอบที่ฝั่ง server ทั้งใน query string และ request body ในการควบคุมจำนวน records ที่จะ response ออกไป</li><li>กำหนดขนาดสูงสุดของ data ที่จะเข้ามาเป็น parameter และส่วนของ payloads ด้วย เช่นจำนวนของ elements ใน arrays หรือ ขนาดของ byte array ใน payload</li></ul><p>ref.</p><ul><li><a href="https://owasp.org/www-project-api-security/">OWASP API Security Project</a></li><li><a href="https://aman-garg.medium.com/implement-custom-validators-using-jsr-based-validations-java-8-spring-f06920877916">Implement custom validators using JSR based validations [Java 8/Spring]</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a49f00334ae" width="1" height="1" alt=""><hr><p><a href="https://medium.com/blog-blog/owasp-api-2019-api-4-lack-of-resources-rate-limiting-6a49f00334ae">OWASP API 2019 : API-4 Lack of Resources &amp; Rate Limiting</a> was originally published in <a href="https://medium.com/blog-blog">blog blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tmux]]></title>
            <link>https://medium.com/blog-blog/tmux-3c44bd9c942?source=rss-9c846f5b6629------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c44bd9c942</guid>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[tmux]]></category>
            <category><![CDATA[command-line]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Nuttapon Pinitpaitoon]]></dc:creator>
            <pubDate>Tue, 08 Dec 2020 04:27:44 GMT</pubDate>
            <atom:updated>2020-12-08T04:27:44.020Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/650/0*w0oTwR4VUdgh_o9_.png" /><figcaption><a href="https://www.shutterstock.com/image-vector/command-line-interface-cli-programming-language-1278851809">https://www.shutterstock.com/image-vector/command-line-interface-cli-programming-language-1278851809</a></figcaption></figure><p>ช่วงหลังๆ มานี้ต้อง remote เข้าไปจัดการ server บ่อยๆ และต้องเปิดหลายๆ Terminal เพื่อจัดการพร้อมๆ กัน ก็เลยไปลองหาวิธีการจัดการกับ Teminal ก็ไปเจอ Tmux มาครับ</p><p>Tmux มันคือ terminal multiplexer แปลของแปลอีกที่ก็ประมาณว่าเป็น tool ที่ช่วยจัดการเรื่อง session ของ terminal และการแสดงผลต่างๆ ของ terminal ให้สะดวกขึ้น</p><p>โดยในส่วนประกอบของ tmux จะมองเป็น 3 ส่วนหลักๆ ครับคือ</p><ul><li>Session คือ Set ของ windows</li><li>Window คือ พื้นที่ที่ใช้แสดงผลประกอบด้วย Pane</li><li>Pane คือ ส่วนที่ใช้แสดงผล มันจะใช้รันคำสั่งๆ ต่างๆ เช่น shell</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*Lj7uB1OEtG3Gqs4_" /><figcaption><a href="https://umarkalim.files.wordpress.com/2014/05/tmux-layout.png?w=400&amp;zoom=2">https://umarkalim.files.wordpress.com/2014/05/tmux-layout.png?w=400&amp;zoom=2</a></figcaption></figure><p>มาเริ่มการใช้งานกันเลยดีกว่า</p><p>เริ่มจากการติดตั้ง Tmux ก่อน ตัวอย่างบน Ubuntu 20.02</p><p><em>$ sudo apt install tmux -y</em></p><p>เริ่มต้นกันที่การจัดการ Session ก่อนครับ</p><ul><li>สร้าง session ใหม่แบบระบุชื่อ</li></ul><p><em>$ tmux new -s &lt;session name&gt;</em></p><p>ระบบจะสร้าง session มาใหม่พร้อมกับ window มาให้ 1 อันและ 1 Pane โดยจะพาเราไปอยู่ที่ session นั้นด้วยเลย ทางด้านมุมขวาล่างจะแสดงข้อมูล session และ window มาให้ครับ (สีเขียวๆ) โดยแสดงข้อมูลดังนี้</p><p>[&lt;session_name&gt;] &lt;window_id&gt;:&lt;window_name&gt;</p><p>ค่าเริ่มต้นของ window_name จะเป็น command ที่รันอยู่ครับ (สามารถเปลี่ยนได้จะอธิบายภายหลังครับ)</p><ul><li>คำสั่ง detach session (ออกจาก session แต่ยังไม่ลบนะ)</li></ul><p>แต่ก่อนอื่นมาเข้าใจการเรียกใช้ command ของ Tmux กันก่อนเมื่อเราเข้ามาใน session ของ tmux แล้วเจ้าที่ tmux จะมี shotcut สำหรับรับคำสั่งเราโดย ตามค่า default แล้วจะเป็นการกด ctrl + b แล้วตามด้วยคำสั่งนะครับ</p><p>ตัวอย่างเช่นคำสั่งเพื่อออกจาก session ปัจจุบันให้กด Ctrl + B แล้วปล่อย จากนั้นกด d ครับ ในที่นี้ผมจะเขียนแบบนี้นะครับ</p><p>[ctrl + B] + d</p><ul><li>ต่อด้วยคำสั่งแสดง session ที่มีทั้งหมด</li></ul><p><em>$ tmux ls</em></p><ul><li>เข้าไปใช้งาน session</li></ul><p>$ tmux a -t &lt;session name&gt;</p><ul><li>คำสั่งลบ session</li></ul><p>$ tmux kill-session -t &lt;session name&gt;</p><p>session จะอยู่จนกว่าเราจะลบมันออก หรือปิดเครื่องไปนะครับ ซึ่งเราสามารถใช้ประโยชน์จาก session นี้ในการทำงานได้เช่นงานที่ต้องรันทิ้งไว้นานๆ แล้วเราอยู่ในระบบ network ที่ไม่ค่อยเสถียร ถ้าเราหลุดไประหว่างทำงาน งานที่รันใน session นั้นๆ ก็ยังคงทำงานต่อไปถึงแม้เราจะหลุดไปแล้วครับ แล้วเราก็ยังกลับเข้ามาใช้งาน session นั้นต่อไปได้เลย</p><p>จากนั้นเรามาดูการจัดการ Window กันต่อครับ (เข้าไปใน session ของ tmux ก่อนนะครับ)</p><ul><li>การสร้าง window ใหม่</li></ul><p>[ctrl + b] + c</p><p>ระบบจะสร้าง window ใหม่มาให้ อีก 1 อันครับโดยมี window_id เป็นเลขเพิ่มขึ้นไป</p><ul><li>การสลับ window</li></ul><p>[ctrl + b] + &lt;window_id&gt;</p><p>(หรือกด ctrl + b + w ระบบจะแสดง window มาแบบ list พร้อม preview ให้เลือกครับ)</p><ul><li>การ rename window</li></ul><p>[ctrl + b] :rename-window &lt;window_name&gt;</p><p>(พิมพ์คำว่า :rename-window ตามด้วยชื่อที่ต้องการไปเลยครับ)</p><p>การจัดการ Pane</p><ul><li>การสร้าง pane ใหม่</li></ul><p>[ctrl + b] + %</p><ul><li>จัดรูปแบบการเรียงของ Pane แบบอัตโนมัติ</li></ul><p>[ctrl + b] + space</p><p>(กดวนๆ ไปเพื่อเปลี่ยนรูปแบบ)</p><p>การออกจาก shell ใดๆ นั้นก็จะทำให้ pane นั้นหลุดไป และถ้าเป็น pane สุดท้ายใน window ก็จะปิด window นั้นไปครับ และสุดท้ายถ้าเป็น window สุดท้ายด้วยก็ปิด session ไปด้วยนะครับ</p><p>Ref.</p><ul><li><a href="https://medium.com/@narate/%E0%B9%84%E0%B8%9C%E0%B9%8B%E0%B8%9A%E0%B9%88%E0%B8%A1%E0%B8%B1%E0%B8%81-tmux-tmux-terminal-multiplexer-ea324838eff2">ไผ๋บ่มัก tmux | tmux — terminal multiplexer</a></li><li><a href="https://linuxize.com/post/getting-started-with-tmux/">Getting started with Tmux</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c44bd9c942" width="1" height="1" alt=""><hr><p><a href="https://medium.com/blog-blog/tmux-3c44bd9c942">Tmux</a> was originally published in <a href="https://medium.com/blog-blog">blog blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[บันทึกการ Subscription RHEL 7]]></title>
            <link>https://nuttaponpinitpaitoon.medium.com/%E0%B8%9A%E0%B8%B1%E0%B8%99%E0%B8%97%E0%B8%B6%E0%B8%81%E0%B8%81%E0%B8%B2%E0%B8%A3-subscription-rhel-7-6bdeb728ff5a?source=rss-9c846f5b6629------2</link>
            <guid isPermaLink="false">https://medium.com/p/6bdeb728ff5a</guid>
            <dc:creator><![CDATA[Nuttapon Pinitpaitoon]]></dc:creator>
            <pubDate>Wed, 02 Sep 2020 03:17:34 GMT</pubDate>
            <atom:updated>2020-09-02T03:17:34.096Z</atom:updated>
            <content:encoded><![CDATA[<p>ถ้าใครยังไม่มี account ก็สามารถเข้าไปได้ที่</p><p><a href="https://access.redhat.com/">Red Hat Customer Portal</a></p><p>จากนั้นก็กลับมาที่เครื่องที่จะ subscription เรียกใช้ command subscription-manager เพื่อ register เครื่องนี้เข้ากับ account ของเรา</p><pre>subscription-manager register --username &lt;username&gt; --password &lt;password&gt; --auto-attach</pre><p>แล้วก็กลับเข้าไปที่หน้า redhat customer portal และเข้าไปที่ menu system จะพบว่ามีเครื่องที่เรา register ไปนั้นโผล่ขึ้นมา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Dd_epUpUc2uiNig8_05gQ.png" /></figure><p>โดยสถานะจะยังไม่ subscribed นะ</p><p>จากนั้นคลิกเข้าไปจะแสดงข้อมูลต่างๆ ของเครืองที่เรา register เข้าไปนั้นขึ้นมา ให้เราก็จะมาทำการผูก subscription ที่เรามีนั้นกับ เครื่องที่ register ไปผ่านทาง menu subscription ได้เลย แล้วเลือกที่ attach subscriptions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*HKzvXExKJpdh--oZKsNSLA.png" /></figure><p>จากนั้นระบบจะพามาให้เลือก subscription ที่จะผูกเข้ากับเครื่องนั้น</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e3VkXXN4lQc1AMRPH_xaMg.png" /></figure><p>แล้วก็กลับมาที่เครื่องที่เรา subscription อีกครั้ง</p><pre>subscription-manager refresh</pre><p>และ</p><pre>subscription-manager attach --auto</pre><p>เท่านี้ก็สามารถเข้าถึง yum repository ของ redhat เพื่อทำการ update ได้แล้วครับ</p><p>อ้างอิง</p><p><a href="https://access.redhat.com/solutions/253273">How to register and subscribe a system to the Red Hat Customer Portal using Red Hat Subscription-Manager - Red Hat Customer Portal</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6bdeb728ff5a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[บันทึกการใช้งาน sqlserver แบบ container]]></title>
            <link>https://medium.com/blog-blog/%E0%B8%9A%E0%B8%B1%E0%B8%99%E0%B8%97%E0%B8%B6%E0%B8%81%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%83%E0%B8%8A%E0%B9%89%E0%B8%87%E0%B8%B2%E0%B8%99-sqlserver-%E0%B9%81%E0%B8%9A%E0%B8%9A-container-550062f47ec4?source=rss-9c846f5b6629------2</link>
            <guid isPermaLink="false">https://medium.com/p/550062f47ec4</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[sql-server]]></category>
            <dc:creator><![CDATA[Nuttapon Pinitpaitoon]]></dc:creator>
            <pubDate>Wed, 18 Dec 2019 02:35:14 GMT</pubDate>
            <atom:updated>2019-12-18T02:40:00.679Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*uZVNKE4jweY5n2KJFOOW6Q.png" /></figure><p>เริ่มกันที่ start sqlserver container ในตัวอย่างนี้จะใช้ version 2017 นะครับ</p><blockquote>docker run — name=sqlserver -d ^<br>-e ACCEPT_EULA=Y ^<br>-e SA_PASSWORD=P@ssw0rd ^<br>-v %cd%/backup:/backup ^<br>-p 1433:1433 ^<br>mcr.microsoft.com/mssql/server:2017-latest</blockquote><p>สำหรับ version อื่นๆ หรือ config เพิ่มเติมเข้าไปดูได้ที่ link ด้านล่างนี้นะ</p><p><a href="https://hub.docker.com/_/microsoft-mssql-server">Microsoft SQL Server - Ubuntu based images</a></p><p>เมื่อ start container แล้วก็ทำการตรวจสอบ status ของ container ผ่าน docker ps และ docker logs -f sqlserver เพือดู log ของ container ครับถ้าไม่มีอะไรผิดพลาดก็พร้อมใช้งานละครับ</p><p>เริ่มต้นจากทดสอบการเชื่อมต่อ database server ที่เพิ่ง start ไปโดยใช้ sqlcmd ผ่านทาง docker exec</p><blockquote>docker exec -it sqlserver /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P P@ssw0rd</blockquote><p>ระบบจะเข้าไปใช้งาน sqlcmd promt ส่งคำสั่ง list ดู database ที่มีใน server</p><blockquote>1&gt; SELECT name, database_id, create_date<br>2&gt; FROM sys.databases;<br>3&gt; GO</blockquote><p>ระบบจะแสดง database ที่มีออกมา</p><p>ในตัวอย่างนี้จะไม่สอนสร้าง database ขึ้นมานะครับแต่จะสอนวิธี restore database จาก backup file มา</p><p>เริ่มต้นจาก copy backup file มาใส่ไว้ที่ folder backup ของ docker host system ครับจะเห็นว่า script start เราได้มีการ map volume /backup เอาไว้แล้วดังนั้นมานำ file มาวางที่นี่ ข้างใน container ก็จะเห็น file นี้ครับ</p><p>เรียกคำสั่ง restore database ได้เลย</p><blockquote>1&gt; RESTORE DATABASE REG_ONE_PVD FROM DISK = “/backup/&lt;your_backup_file&gt;.bak”<br> 2&gt; GO</blockquote><p>แต่ว่าส่วนใหญ่แล้ว path file ที่ระบุใน backup file จะไม่ตรงกับใน container ดังนั้นเราจึงต้องมีการระบุบอก restore ว่าให้ไปยังที่ที่เราต้องการครับ</p><p>ตรวจสอบว่า path file ต่างที่ระบุใน backup เป็นอย่างไรด้วยคำสั่ง</p><blockquote>1&gt; RESTORE FILELISTONLY FROM DISK = “/backup/&lt;your_backup_file&gt;.bak”<br> 2&gt; GO</blockquote><p>ระบบจะแสดงชื่อและ path ที่ backup ออกมาให้เราจำชื่อ primary ไว้นะครับ</p><p>จากนั้นปรับแต่งคำสั่ง restore นิดหน่อยตามนี้ครับ</p><blockquote>1&gt; RESTORE DATABASE &lt;database_name&gt;FROM DISK = “/backup/&lt;your_backup_file&gt;.bak” WITH MOVE “&lt;primary_name&gt;” TO “/var/opt/mssql/data/&lt;database_name&gt;.mdf”, MOVE “&lt;primary_log_name&gt;” TO “/var/opt/mssql/data/&lt;database_name&gt;.ldf”<br> 2&gt; GO</blockquote><p>สามารถปรับแต่ง path ได้ตามต้องการนะครับ</p><p><strong>BACKUP DATABASE</strong></p><p>ต่อมาก็มาดูการทำ backup กันครับ</p><blockquote>1&gt; BACKUP DATABASE &lt;database_name&gt; TO DISK=”/backup/&lt;backup_file_name&gt;.bak”<br> 2&gt; GO</blockquote><p>แถมให้อีกคำสั่งครับไว้สำหรับ rename database</p><blockquote>1&gt; ALTER DATABASE &lt;from_database_name&gt; MODIFY NAME = &lt;to_database_name&gt;<br> 2&gt; GO</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=550062f47ec4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/blog-blog/%E0%B8%9A%E0%B8%B1%E0%B8%99%E0%B8%97%E0%B8%B6%E0%B8%81%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%83%E0%B8%8A%E0%B9%89%E0%B8%87%E0%B8%B2%E0%B8%99-sqlserver-%E0%B9%81%E0%B8%9A%E0%B8%9A-container-550062f47ec4">บันทึกการใช้งาน sqlserver แบบ container</a> was originally published in <a href="https://medium.com/blog-blog">blog blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[บันทึกการสร้าง docker image]]></title>
            <link>https://medium.com/blog-blog/%E0%B8%9A%E0%B8%B1%E0%B8%99%E0%B8%97%E0%B8%B6%E0%B8%81%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%AA%E0%B8%A3%E0%B9%89%E0%B8%B2%E0%B8%87-docker-image-42bc3ec050ec?source=rss-9c846f5b6629------2</link>
            <guid isPermaLink="false">https://medium.com/p/42bc3ec050ec</guid>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Nuttapon Pinitpaitoon]]></dc:creator>
            <pubDate>Fri, 26 Jul 2019 03:12:14 GMT</pubDate>
            <atom:updated>2019-07-26T03:12:14.211Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*X39T-HELWw6V2D6YYIkHpg.png" /><figcaption><a href="https://medium.com/platformer-blog/practical-guide-on-writing-a-dockerfile-for-your-application-89376f88b3b5">https://medium.com/platformer-blog/practical-guide-on-writing-a-dockerfile-for-your-application-89376f88b3b5</a></figcaption></figure><p><strong>วิธีการเพิ่ม path เข้าไปในตัวแปร PATH</strong></p><p>สำหรับการ build image ขึ้นมาเองบางครั้งเราต้องมีการเพิ่ม path ที่ใช้งานเข้าไปใน docker image ซึ่งสามารถทำได้โดยการเพิ่มคำสั่งนี้ลงใน Dockerfile</p><p>ENV PATH=”[new path]:${PATH}”</p><p>ตัวอย่าง</p><p>ENV PATH=”/opt/jmeter/bin:${PATH}”</p><p><strong>วิธีการรัน supervisord แบบ non-root user</strong></p><p>การสร้าง docker image จะมีคำแนะนำทาง security แนะนำให้รัน image นั้นด้วย user ที่ไม่ใช่ root ซึ่งเมื่อ image ของเรามีการใช้งาน supervisor ในการควบคุม service ใน image ทำให้ต้องปรับแต่ง supervisor config ให้รันใน mode ที่ไม่ใช่ root (ค่า default จะรันด้วย root)</p><p>สำหรับการปรับแต่งสามารถทำได้โดยเปลี่ยนไปใช้ inet_http_server แทนการใช้งาน unix_http_server</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*FyUZthFqrpsZYSMk3FAY4g.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42bc3ec050ec" width="1" height="1" alt=""><hr><p><a href="https://medium.com/blog-blog/%E0%B8%9A%E0%B8%B1%E0%B8%99%E0%B8%97%E0%B8%B6%E0%B8%81%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%AA%E0%B8%A3%E0%B9%89%E0%B8%B2%E0%B8%87-docker-image-42bc3ec050ec">บันทึกการสร้าง docker image</a> was originally published in <a href="https://medium.com/blog-blog">blog blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SSL Certificate File Description]]></title>
            <link>https://medium.com/blog-blog/ssl-certificate-file-description-ce08ce397410?source=rss-9c846f5b6629------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce08ce397410</guid>
            <category><![CDATA[ssl]]></category>
            <dc:creator><![CDATA[Nuttapon Pinitpaitoon]]></dc:creator>
            <pubDate>Thu, 27 Jun 2019 04:52:10 GMT</pubDate>
            <atom:updated>2020-12-29T10:28:57.615Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*Y4lLehTNHX372fQX0IBKMw.png" /><figcaption><a href="https://www.usgs.gov/products/data-and-tools/data-management/file-formats">https://www.usgs.gov/products/data-and-tools/data-management/file-formats</a></figcaption></figure><p>SSL has been around for long enough you’d think that there would be agreed upon container formats. And you’re right, there are. Too many standards as it happens. So this is what I know, and I’m sure others will chime in.</p><ul><li><strong>.csr</strong> — This is a Certificate Signing Request. Some applications can generate these for submission to certificate-authorities. The actual format is PKCS10 which is defined in <a href="https://tools.ietf.org/html/rfc2986">RFC 2986</a>. It includes some/all of the key details of the requested certificate such as subject, organization, state, whatnot, as well as the <em>public key</em> of the certificate to get signed. These get signed by the CA and a certificate is returned. The returned certificate is the public <em>certificate</em>(which includes the public key but not the private key), which itself can be in a couple of formats.</li><li><strong>.pem</strong> — Defined in RFCs <a href="https://tools.ietf.org/html/rfc1421">1421</a> through <a href="https://tools.ietf.org/html/rfc1424">1424</a>, this is a container format that may include just the public certificate (such as with Apache installs, and CA certificate files /etc/ssl/certs), or may include an entire certificate chain including public key, private key, and root certificates. Confusingly, it may also encode a CSR (e.g. as used <a href="https://jamielinux.com/docs/openssl-certificate-authority/create-the-intermediate-pair.html">here</a>) as the PKCS10 format can be translated into PEM. The name is from <a href="https://en.wikipedia.org/wiki/Privacy-enhanced_Electronic_Mail">Privacy Enhanced Mail (PEM)</a>, a failed method for secure email but the container format it used lives on, and is a base64 translation of the x509 ASN.1 keys.</li><li><strong>.key</strong> — This is a PEM formatted file containing just the private-key of a specific certificate and is merely a conventional name and not a standardized one. In Apache installs, this frequently resides in /etc/ssl/private. The rights on these files are very important, and some programs will refuse to load these certificates if they are set wrong.</li><li><strong>.pkcs12 .pfx .p12</strong> — Originally defined by RSA in the <a href="https://en.wikipedia.org/wiki/PKCS">Public-Key Cryptography Standards</a>(abbreviated PKCS), the “12” variant was originally enhanced by Microsoft, and later submitted as <a href="https://tools.ietf.org/html/rfc7292">RFC 7292</a>. This is a passworded container format that contains both public and private certificate pairs. Unlike .pem files, this container is fully encrypted. Openssl can turn this into a .pem file with both public and private keys: openssl pkcs12 -in file-to-convert.p12 -out converted-file.pem -nodes</li></ul><p>A few other formats that show up from time to time:</p><ul><li><strong>.der</strong> — A way to encode ASN.1 syntax in binary, a .pem file is just a Base64 encoded .der file. OpenSSL can convert these to .pem (openssl x509 -inform der -in to-convert.der -out converted.pem). Windows sees these as Certificate files. By default, Windows will export certificates as .DER formatted files with a different extension. Like...</li><li><strong>.cert .cer .crt</strong> — A .pem (or rarely .der) formatted file with a different extension, one that is recognized by Windows Explorer as a certificate, which .pem is not.</li><li><strong>.p7b .keystore</strong> — Defined in <a href="https://tools.ietf.org/html/rfc2315">RFC 2315</a> as PKCS number 7, this is a format used by Windows for certificate interchange. Java understands these natively, and often uses .keystore as an extension instead. Unlike .pem style certificates, this format has a <em>defined</em> way to include certification-path certificates.</li><li><strong>.crl</strong> — A certificate revocation list. Certificate Authorities produce these as a way to de-authorize certificates before expiration. You can sometimes download them from CA websites.</li></ul><p>In summary, there are four different ways to present certificates and their components:</p><ul><li><strong>PEM</strong> — Governed by RFCs, its used preferentially by open-source software. It can have a variety of extensions (.pem, .key, .cer, .cert, more)</li><li><strong>PKCS7</strong> — An open standard used by Java and supported by Windows. Does not contain private key material.</li><li><strong>PKCS12</strong> — A Microsoft private standard that was later defined in an RFC that provides enhanced security versus the plain-text PEM format. This can contain private key material. Its used preferentially by Windows systems, and can be freely converted to PEM format through use of openssl.</li><li><strong>DER</strong> — The parent format of PEM. It’s useful to think of it as a binary version of the base64-encoded PEM file. Not routinely used very much outside of Windows.</li></ul><p>Ref</p><p><a href="https://serverfault.com/questions/9708/what-is-a-pem-file-and-how-does-it-differ-from-other-openssl-generated-key-file">What is a Pem file and how does it differ from other OpenSSL Generated Key File Formats?</a></p><p>เพิ่มเติมสำหรับใครที่ต้องการ convert จาก file .jks(jboss) ไปใช้งานกับ nginx ที่ต้องการเป็น .pem และ .key ครับ</p><ol><li>Convert our “.jks” file to “.p12” (PKCS12 keystore format): keytool -importkeystore -srckeystore { java-keystore.jks } -destkeystore { pkcs12-keystore.p12 } -deststoretype PKCS12</li><li>2. Extract pem (certificate) from “.p12” keystore file: openssl pkcs12 -nokeys -in { pkcs12-keystore.p12 } -out { certificate-chain.pem }</li><li>3. Extract unencrypted key file from “.p12” keystore file: openssl pkcs12 -nocerts -nodes -in { pkcs12-keystore.p12 } -out { unencrypted-key.key }</li></ol><p>Ref</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3bdf8b5ba15ec4dceabb6a6888e00236/href">https://medium.com/media/3bdf8b5ba15ec4dceabb6a6888e00236/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce08ce397410" width="1" height="1" alt=""><hr><p><a href="https://medium.com/blog-blog/ssl-certificate-file-description-ce08ce397410">SSL Certificate File Description</a> was originally published in <a href="https://medium.com/blog-blog">blog blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>