ตาราง APDU บัตรประจำตัวประชาชน https://github.com/chakphanu/ThaiNationalIDCard/blob/master/APDU.md
Add leading zero to ISDN PRI
ปิด Linux network interface name แบบง่ายๆ
ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules
สรุปย่อ Docker volume
สรุปเรื่อง docker volume จาก Manage data in containers
- volume จะไม่ถูกลบออกแม้ว่าจะได้ลบ container ไปแล้ว
- เมื่อเพิ่ม volume โดยไม่ระบุต้นทาง Docker จะสร้าง directory สุ่มให้ใน /var/lib/docker/volumes/สุ่ม/_data
- การระบุต้นทาง ทำได้ทั้งแบบระบุ absolute path เช่น /c/Users/jane/Projects/test1/html:/var/www/html
- หรือกำหนดเป็นชื่อ เช่น test1_html:/var/www/html ตัว Docker จะสร้าง volume เก็บไว้ที่ /var/lib/docker/volumes/test1_html/_data
- ค่าเริ่มต้นที่ Docker machine กำหนดให้สามารถ mount volume จากเครื่อง host ได้คือ /Users/…. (OS X) หรือ C:\Users\…. เท่านั้น
ทดสอบ dhcp server ใน docker over vm เจอปัญหา UDP checksum
ปัญหาเกิดจาก driver virtio checksum ซึ่งรันบน host จริง ไม่น่ามีปัญหา(ยังไม่ได้ทดสอบ)
แต่ตอนนี้แก้ปัญหาชั่วคราวด้วย iptables
iptables -t mangle -A PREROUTING -i docker0 -p udp --dport 67 -j CHECKSUM --checksum-fill iptables -t mangle -A PREROUTING -i docker0 -p udp --dport 68 -j CHECKSUM --checksum-fill iptables -t mangle -A POSTROUTING -o ethX -p udp --dport 67 -j CHECKSUM --checksum-fill iptables -t mangle -A POSTROUTING -o ethX -p udp --dport 68 -j CHECKSUM --checksum-fill
ย้าย blog มารันบน Docker เจอปัญหา WordPress กับ Reverse SSL Proxy
วันนี้ได้ทำการย้าย Blog jane.in.th มารันบน Docker เรียบร้อย โดยใช้ container ต่างๆ ดังนี้
- mysql:5.7
- php:7.0-apache
- jwilder/nginx-proxy ใช้ทำ Reverse proxy ทั้ง http และ https
- jrcs/letsencrypt-nginx-proxy-companion ใช้สำหรับสร้าง Cerfiticate จาก Let’s Encrypt อัตโนมัต(ทำงานร่วมกับ jwilder/nginx-proxy )
ปัญหามีอยู่ว่า พอรัน WordPress ผ่าน Reverse SSL Proxy แล้ว เดี๊ยง ก็เลยไปค้นเจอวิธีแก้จาก http://codex.wordpress.org/Administration_Over_SSL
โดยแก้ wp-config.php เพิ่มดังนี้
/* สองบรรทัดนี้ เป็น option ไม่ใส่ก็ได้ */ define('FORCE_SSL_LOGIN', true); define('FORCE_SSL_ADMIN', true); /* แก้ปัญหา Reverse SSL Proxy */ if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') $_SERVER['HTTPS']='on';
Classic ASP สร้าง Pre-signed GET Object
เนื่องจากว่าที่ทำงาน มี Classic ASP application มีการดึงรูป นศ. จาก FTP(localhost) มาแสดงหน้า profile ของ นศ.
ความต้องการใหม่คือย้ายรูปจาก local filesystem/FTP(localhost) ไปไว้ใน Object storage
ก็เลยไปค้นในเน็ต ว่ามีใครบ้างที่ทำไว้แล้ว ก็เจอข้อมูลตามนี้
http://stackoverflow.com/questions/14126243/hash-hmac-in-using-pure-classic-asp
https://precompiled.wordpress.com/2007/11/26/hmac-sha1-encryptie-onder-classic-asp/
https://forums.aws.amazon.com/message.jspa?messageID=147377
เลยได้ลอง coding ทดสอบ จึงได้ code ที่ทำงานได้ตามต้องการ ตามนี้
<%@ Language=VBScript %> <% Dim awskey, awsscret, requestSign, objKey, bucket, host, proto Dim expire, sig, result, url1, url2 Dim sha1 awskey = "access key" awsscret = "secret" expire = 1457400000 'unix timestamp to expire bucket = "bucket name" objKey = "object key" host = "s3.example.com" proto = "https" requestSign = "GET" & vbLf & vbLf & vbLf & expire & vbLf & "/" & bucket & "/" & objKey set sha1 = GetObject("script:" & Server.MapPath("sha1.wsc")) sha1.hexcase = 0 result = sha1.b64_hmac_sha1(awsscret, requestSign) sig = Server.URLEncode(result & "=") url1 = proto & "://" & host & "/" & bucket & "/" & objKey & "?AWSAccessKeyId=" & awskey & "&Signature=" & sig & "&Expires=" & expire url2 = proto & "://" & bucket & "." & host & "/" & objKey & "?AWSAccessKeyId=" & awskey & "&Signature=" & sig & "&Expires=" & expire %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>S3</title> </head> <body> Request Signature : <%= requestSign %> <br/> HMAC-SHA1 result: <%= result %> <br/> Signature result: <%= sig %> <br/> URL Path style: <a href="<%= url1 %>" target="_blank"><%= url1 %></a> <br/> URL Virtual style: <a href="<%= url2 %>" target="_blank"><%= url2 %></a> <br/> </body> </html> <% 'Free resource Set sha1 = Nothing %>
sha1.wsc ค้นใน Google ได้มาจาก http://uwblog.googlecode.com/svn/trunk/includes/sha1.wsc
และสำรองไว้แล้วใน Github เผื่ออนาคตมันหายไป
อ่านบัตรประจำตัวประชาชนด้วย C#
ตัวอย่าง code ได้ upload ไว้แล้วที่ https://github.com/chakphanu/ThaiNationalIDCard.Example
Bypass Cisco 6500 Req high speed fan & PSU
rommon >ALLOWANYFAN=1 rommon >ALLOWANYPS=1 rommon >sync
เพิ่ม autoboot
เข้า confreg
เปลี่ยน boot characteristic จาก 0 เป็น 1
Ceph Object Gateway & S3 API
ลองเล่น Ceph S3 โดยใช้ AWS PHP SDK v2 http://docs.aws.amazon.com/aws-sdk-php/v2/guide/installation.html
ไม่มีอะไร มาแชร์ข้อสังเกตุที่เจอดังนี้
<?php require 'vendor/autoload.php'; use Aws\S3\S3Client; /* * ต้องทำ wildcard ชี้ *.s3.example.com ไปยัง Ceph RadosGW node * เพราะว่า bucket student.image จะชี้ไปที่ student.image.s3.example.com */ $s3 = S3Client::factory([ 'key' => 'photo.student key', 'secret' => 'photo.student secret', 'endpoint' => 'http://s3.example.com' ]); /* สร้าง bucket student.image */ $s3->createBucket(['Bucket' => 'student.image']); /* * ทดสอบตั้งค่า ACL ให้ Bucket โดยที่การ putBucketAcl() จะเป็นการทับ ACL เดิมทั้งหมด * ดังนั้น จึงต้องใส่ค่า Owner และ Grant Owner ด้วย */ $result = $s3->putBucketAcl([ 'Owner' => [ 'DisplayName' => 'Students Photo Bucket', 'ID' => 'photo.student', ], 'Grants' => [ [ 'Grantee' => [ 'Type' => 'CanonicalUser', 'ID' => 'photo.student', ], 'Permission' => 'FULL_CONTROL', ], /* grant read uid=photo.student.ro ให้ อ่านรายชื่อ object ใน bucket student.image ได้ */ [ 'Grantee' => [ 'Type' => 'CanonicalUser', 'ID' => 'photo.student.ro', ], 'Permission' => 'READ', ], ], 'Bucket' => 'student.image', ]); /* dump ACL bucket student.image */ var_dump($s3->getBucketAcl([ 'Bucket' => 'student.image', ])); /* ทำการ upload test.jpg พร้อมกำหนด ACL */ $s3->putObject([ 'Bucket' => 'student.image', 'Key' => 'test', 'Body' => fopen("test.jpg", 'r'), 'GrantRead' => 'id=photo.student.ro', 'GrantFullControl' => 'id=photo.student', ]); /* ทดสอบด้วย Read only account */ $s3ro = S3Client::factory([ 'key' => 'photo.student.ro key', 'secret' => 'photo.student.ro secret', 'endpoint' => 'http://s3.example.com' ]); /* ทำการสร้าง url สำหรับเรียกดู test.jpg โดย url จะมีอายุ 1 นาที */ $command = $s3ro->getCommand('GetObject', [ 'Bucket' => 'student.image', 'Key' => 'test', ]); $signedUrl = $command->createPresignedUrl('+1 minutes'); echo "{$signedUrl}\n";