การตั้งค่า NGINX ให้ใช้กับ Let’s Encrypt และได้เกรด A+ จาก SSL Labs

ช่วงหลังๆ มานี่ปริมาณเว็บไซต์ที่ใช้ HTTPS เพิ่มขึ้นอย่างมาก ทั้งด้วยปัจจัยเรื่องความเป็นส่วนตัวของผู้ใช้ การแอบดักข้อมูลของรัฐบาล การที่คอมพิวเตอร์เซิร์ฟเวอร์มันเร็วขึ้นมากจนรองรับการเข้ารหัสกับผู้ใช้ทุกคนได้ จนไปถึง SSL ไม่ต้องเสียเงินอีกต่อไป ด้วยเหตุผลที่กล่าวมาข้างต้น ดังนั้นเว็บไซต์ยุคใหม่ควรจะปรับตัวและใช้ HTTPS ให้เรียบร้อยได้แล้ว วันนี้จึงจะมาสอนตั้งค่า NGINX ให้ได้ HTTPS สวยๆ แบบไม่ต้องเสียค่า Certificate สำหรับ SSL กัน แต่ก่อนอื่นต้องบอกว่านี่ไม่ใช่โพสที่จะสอนว่าเปิด Web Server ยังไงนะครับ นี่เป็นระดับผู้ที่ใช้งานเป็นแล้วพอสมควร Continue reading

Rewrite Laravel URL when not in root path with NGINX

In the most cases, we place the Laravel in the root path /.

As a result, the nginx configuration becomes

However, if we want to move Laravel inside other directories, we must also change the location directive along with the public/index.php file.

Let’s say we want to move to the /app directory. Then the location directive would become

Since nginx indicates the root path already, so we have to always refer from the root path.