Author Topic: enable https:// for login directadmin control panel  (Read 5205 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2141
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
enable https:// for login directadmin control panel
« on: กรกฎาคม 27, 2016, 01:24:36 PM »
ถ้าเราต้องการที่จะเพิ่มความปลอดภัยให้กับหน้า login โดยให้ใช้งานผ่าน
https://yourdomain.com:2222

สามารถแก้ไขได้ตามนี้ครับ
โดยทำการลง  link ก่อน

#/usr/bin/openssl req -x509 -sha256 -newkey rsa:4096 -keyout /usr/local/directadmin/conf/cakey.pem -out /usr/local/directadmin/conf/cacert.pem -days 9000 -nodes

#chown diradmin:diradmin /usr/local/directadmin/conf/cakey.pem
#chmod 400 /usr/local/directadmin/conf/cakey.pem


กรณีแรกถ้าเป็น Certificate ที่ซื้อมา
ทำตามนี้ ครับผม

certificate:  /usr/local/directadmin/conf/cacert.pem
key: /usr/local/directadmin/conf/cakey.pem

ทำการแก้ไขไฟล์ /usr/local/directadmin/conf/directadmin.conf โดยทำการเปลี่ยนค่าให้เป็น SSL=1  (default is 0). 
ตัวนี้เป็นการบอกให้ DA ทำการ login ผ่าน SSL Protocol
Ensure your directadmin.conf has the values set:
cacert=/usr/local/directadmin/conf/cacert.pem
cakey=/usr/local/directadmin/conf/cakey.pem

สามารถเปลี่ยนค่า path ตามที่ชอบได้เลยครับ

เสร็จแล้วทำการ restart directadmin service
#/etc/init.d/directadmin restart

ถ้ามีใช้งาน CA-root-cert สามารถแก้ไขที่
carootcert=/usr/local/directadmin/conf/carootcert.pem

into the /usr/local/directadmin/conf/directadmin.conf file (won't exist by default) and by pasting the contents of the caroot cert into that file.

Using the free "Let's Encrypt" tool to secure 2222


ในกรณีเป็น Cert ที่ไม่ได้ซื้อให้ทำการสร้าง key ให้กับ hostname ของท่าน
cd /usr/local/directadmin/scripts
./letsencrypt.sh request your.hostname.com 4096

ทำการระบุข้อมูลให้ครับ

ทำการปรับแก้ไขใน ไฟล์ config และเพิ่ม configure ดังนี้ โดยแก้ไข your.hostname.com เป็นชื่อ โฮสของคุณครับ
#cd /usr/local/directadmin/conf
#perl -pi -e 's/SSL=0/SSL=1/' directadmin.conf
#echo "carootcert=/usr/local/directadmin/conf/carootcert.pem" >> directadmin.conf
#echo "force_hostname=your.hostname.com" >> directadmin.conf
#echo "ssl_redirect_host=your.hostname.com" >> directadmin.conf
#/etc/init.d/directadmin restart

ขอบคุณลิ้งจาก : https://help.directadmin.com/item.php?id=15
« Last Edit: กรกฎาคม 27, 2016, 01:40:45 PM by golfreeze »

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2141
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: enable https:// for login directadmin control panel
« Reply #1 on: มกราคม 11, 2017, 02:59:47 PM »
การแปลง .crt ( Certificate file ) เป็น .pem
#cat server.crt server.key > server.includesprivatekey.pem

Encodings (also used as extensions)

.DER = The DER extension is used for binary DER encoded certificates. These files may also bear the CER or the CRT extension.   Proper English usage would be “I have a DER encoded certificate” not “I have a DER certificate”.
.PEM = The PEM extension is used for different types of X.509v3 files which contain ASCII (Base64) armored data prefixed with a “—– BEGIN …” line.
Common Extensions

.CRT = The CRT extension is used for certificates. The certificates may be encoded as binary DER or as ASCII PEM. The CER and CRT extensions are nearly synonymous.  Most common among *nix systems
CER = alternate form of .crt (Microsoft Convention) You can use MS to convert .crt to .cer (.both DER encoded .cer, or base64[PEM] encoded .cer)  The .cer file extension is also recognized by IE as a command to run a MS cryptoAPI command (specifically rundll32.exe cryptext.dll,CryptExtOpenCER) which displays a dialogue for importing and/or viewing certificate contents.
.KEY = The KEY extension is used both for public and private PKCS#8 keys. The keys may be encoded as binary DER or as ASCII PEM.
The only time CRT and CER can safely be interchanged is when the encoding type can be identical.  (ie  PEM encoded CRT = PEM encoded CER)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2141
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: enable https:// for login directadmin control panel
« Reply #2 on: มกราคม 11, 2017, 03:47:11 PM »
#openssl req -new -newkey rsa:2048 -nodes -sha256 -out web.csr
ใส่ข้อมูลต่างๆ ลงไปเช่น พวก ประเทศ ที่อยู่ office