SlideShare a Scribd company logo
Linux Server Admin


  Web Applications
    Chatchai J

    2013-01-14
    2013-01-16
Application on Web
●   Using Web as User Interface
●   Example
    –   Database : phpmyadmin
        ●   php, mysql
    –   Mail : web mail
        ●   roundcube
        ●   squirrelmail
    –   Weblog – blog
        ●   wordpress
phpmyadmin
●   ติดตั้ง
        $ sudo apt-get install phpmyadmin
●   config
    –   เลือก apache2 เป็ น Web Server

    –   admin password สำำหรับ mysql server (root)

    –   password สำำหรับ phpmyadmin
        ●   LEAVE IT BLANK (phpmyadmin จะ gen random password ให้)
phpmyadmin (ต่อ)
●   ทดสอบที่ URL
    http://www.domain.com/phpmyadmin
    http://172.30.160.xx/phpmyadmin
●   login โดยใช้ admin account ของ mysql
    –   login:
    –   password:
●   ใช้งำนได้แล้ว!
ในกรณีที่มีปัญหำ
➔   apache web server ทำำงำนอย่่หรือเปล่ำ?
    $ ps uaxw | grep apache

    ถ้ำไม่ แก้ปัญหำ config ของ apache ก่อน
    $ sudo apachectl configtest

    ด่วำมี error ที่ใหนแล้วแก้ไขให้ถ่กต้อง
       ่
  $ sudo apachectl restart
ในกรณีที่มีปัญหำ (ต่อ)
➔   เปิ ด webbrowser (firefox, lynx, epiphany, chromium-browser)
    $ firefox localhost
➔   ควรที่จะใช้งำนได้, ถ้ำไม่ได้ → ยกมือถำม

➔   เปลี่ยนจำก localhost เป็ น ip address

      * ตรวจสอบให้แน่ใจว่ำ IP address ของเครื่อง VM คืออะไร ก่อนเปิ ด

    $ firefox http://172.30.160.XX
➔   ควรที่จะใช้งำนได้, ถ้ำไม่ได้ → ยกมือถำม
ในกรณีที่มีปัญหำ (ต่อ)
➔   เปิ ดโดยใช้ domain name (www.domain.com) 
    $ firefox http://www.domain.com
➔   ถ้ำมีปัญหำ ให้ตรวจสอบ DNS
    $ host ­t a www.domain.com localhost
    $ host ­t a www.domain.com 172.30.0.85
    $ host ­t a www.domain.com lsa­svr.coe.psu.ac.th
    $ host ­t a www.domain.com

➔   ทุกคำำสั่งควรจะให้คำำตอบเดียวกัน คือ IP Address ของ
    เครื่อง VM ของคุณในตอนนี้
ถ้ำ lookup address แล้วมีปัญหำ
●   ไฟล์ /etc/resolv.conf ของ VM (และของ host) จะต้องมีข้อม่ลดังนี้
        domain coe.psu.ac.th
        search coe.psu.ac.th
        nameserver 172.30.0.85
●   ยกเว้นว่ำ คุณร้่ว่ำมันมีควำมหมำยว่ำอย่ำงไร
    (ซึ่ งคุณควรจะร้่) และจะใช้วิธีกำรอื่นได้อย่ำงไร

●   VM จะต้องส่ง notification ไปยัง lsa-svr.coe.psu.ac.th เพื่อ register
    domain ของตัวเองให้ lsa-svr ร้่จัก

    –   update serial ใน ZONE file แล้วใช้ rndc reload
ปั ญหำของ DNS
    $ host ­t a www.domain.com localhost

●   ถ้ำไม่สำมำรถ resolve ได้แสดงว่ำ named server บน
    VM มีปัญหำ

●   ตรวจสอบว่ำ named run อย่่หรือเปล่ำ?
      $ ps auxw | grep named
●   ถ้ำไม่มีให้ start bind9
      $ sudo service bind9 start
ปั ญหำของ DNS (ต่อ)
●   ถ้ำ start named ไม่ได้ ให้ตรวจสอบ config ของ named
      $ named­checkconf
      $ named­checkconf ­z
●   ทั้งสองคำำสั่ง จะต้องไม่มี error ถ้ำมี ให้แก้ไขให้ถ่กต้อง ถ้ำยังแก้ไม่ได้ → ยกมือถำม
      $ sudo service bind9 restart
      $ sudo rndc reload
●   แล้วตรวจสอบ log ใน /var/log/syslog
      $ sudo grep named /var/log/syslog | tail ­25
●   จะต้องมีข้อควำม “running” หรือ “reload configuration succeeded”

●   มีข้อควำม “zone domain.com/IN: sending notified (serial xxxxxxxxxx)”
ปั ญหำของ DNS (ต่อ)
    $ host ­t a www.domain.com 172.30.0.85
    $ host ­t a www.domain.com lsa­svr.coe.psu.ac.th

●   ถ้ำไม่สำมำรถ resolve ได้แสดงว่ำ ข้อม่ลของ zone มีปัญหำ

●   ใน zone ไฟล์ /var/cache/bind/master/domain.com จะต้องมี

    –   record ของ NS 2 record
        $ORIGIN domain.com.
                        IN NS lsa­svr.coe.psu.ac.th.
                        IN NS ns.domain.com.
    –   Note: บรรทัด $ORIGIN มีควำมสำำคัญ

    –   และมี A record ของ ns.domain.com ซึ่งมี IP Address เป็ นของ VM ในขณะนี้
        ns              IN A 172.30.160.xx
ปั ญหำของ DNS (ต่อ)
●   ทุกครั้งที่แก้ไข zone ไฟล์ ให้ update serial
    ของ SOA เสมอ

●   หลังจำกแก้ไขเสร็จ reload config แล้ว
    ตรวจสอบอีกครั้ง

●   ถ้ำยังใช้งำนไม่ได้ → ยกมือถำม
กลับมำที่ www
●   ถึงตอนนี้ควรทีจะใช้งำน
                  ่
      $ firefox http://www.domain.com
●   จำก VM (และจำก host ถ้ำ nameserver เป็ น
    172.30.0.85) ได้แล้ว

●   ต่อไปเป็ นกำรเข้ำถึง phpmyadmin
      $ firefox http://www.domain.com/phpmyadmin
phpmyadmin
●   ถ้ำเข้ำถึง http://www.domain.com ได้
    แต่ http://www.domain.com/phpmyadmin ยังไม่ได้

●   จะเป็ นปั ญหำที่ config ของ phpmyadmin

●   ตรวจสอบด่ว่ำมีไฟล์ /etc/apache2/conf.d/phpmyadmin.conf หรือเปล่ำ
    $ ls ­l /etc/apache2/conf.d | grep phpmyadmin
●   ควรจะมีไฟล์ config ใน /etc/phpmyadmin/apache.conf อย่แล้ว
                                                         ่
    $ ls ­l /etc/phpmyadmin/apache.conf
    –   ถ้ำไม่มี ให้ตดตั้ง phpmyadmin ใหม่
                     ิ
phpmyadmin
●   สร้ำง link จำก /etc/phpmyadmin/apache.conf ไป
    ไว้ใน /etc/apache2/conf.d
    $ cd /etc/apache2/conf.d
    $ sudo ln ­sf /etc/phpmyadmin/apache.conf phpmyadmin.conf

●   restart apache2 ใหม่ ทุกครั้งหลังจำกมีกำรเปลี่ยนแปลง
    config
    $ sudo service apache2 restart
phpmyadmin
●   ติดตั้ง phpmyadmin ใหม่
    $ sudo apt­get purge phpmyadmin
    $ sudo rm ­rvf /etc/phpmyadmin
    $ sudo apt­get install phpmyadmin
ปั ญหำ!!!
●   ผ่ำนทำง web interface

●   ส่งข้อม่ลแบบ plain text

●   login/password สำำหรับ database ซึ่งสำมำรถ แก้ไขข้อม่ลใดๆ
    ก็ได้ในฐำนข้อม่ลทั้งหมด

●
    YOU SHOULD NOT DOING SOMETHING LIKE THAT!
●   วิธีกำรแก้ไข เข้ำรหัสกำรติดต่อ โดยใช้ https
เข้ำรหัส HTTP
●   ใช้ https

●   ssl เป็ น module ของ apache2

●   สำมำรถ enable โดยใช้ “a2enmod ssl”
      $ sudo a2enmod ssl
      $ sudo service apache2 restart
เข้ำรหัส HTTP (ต่อ)
●   config ของ apache สำำหรับ ssl แยกออกมำจำก
    default ซึ่งไม่ได้เข้ำรหัส

●   ด่ไฟล์ใน /etc/apache2/sites-available และ /etc/sites-
    enabled
●   สำมำรถ enable โดยใช้คำำสั่ง a2ensite
      $ sudo a2ensite default­ssl
      $ sudo service apache2 restart
https connection
●   สำมำรถ connect โดยใช้
        https://www.domain.com
    –   จะต้อง trust key ที่สร้ำงขึ้นมำก่อน เพรำะเป็ นแบบ self-signed

●   ใช้งำนได้แล้ว?
        https://www.domain.com/phpmyadmin
        แล้ว

        http://www.domain.com/phpmyadmin ล่ะ?
อันตรำยจำก phpmyadmin
●   มี zombie bot จำำนวนมำกใช้วิธีกำร bruteforce attack อย่่
    จำำนวนมำก

●   ตัวอย่ำงบน publish-paper

●   กำรป้ องกัน
    –   mysql administrator password MUST secure
    –   update/upgrade phpmyadmin อย่่เสมอ

    –   ซ่อนมันไว้หลัง virtualhost อื่น
เพิ่ม name ต่อไปนี้ใน Zone file
●
    shell
●
    webmail
●   pma (phpmyadmin)
●
    webmin
●
    blog

      pma IN A 172.30.160.xxx
      shell IN A 172.30.160.xxx
      ...
●   เพื่อให้สำมำรถใช้ช่ อ pma.domain.com (และอื่ นๆ) ได้
                        ื
virtualhost config
●   เรำจะใช้ https://pma.domain.com
    สำำหรับกำรเข้ำถึง phpmyadmin เท่ำนั้น
    ไม่สำมำรถเข้ำจำกทำงอื่นได้

●   ด่ตัวอย่ำงกำร config virtualhost ของ
    https://www.domain.com จำก
    /etc/apache2/sites-available/default-ssl
virtual host
●   เริ่มจำก http://pma.mydomain.com ให้เข้ำถึง
    phpmyadmin
●   ใช้ NameVirtualHost และ VirtualHost

●   ในไฟล์ /etc/phpmyadmin/apache.conf
/etc/phpmyadmin/apache.conf
NameVirtualHost pma.domain.com:80

<VirtualHost pma.domain.com:80>

# Alias /phpmyadmin /usr/share/phpmyadmin
DocumentRoot /usr/share/phpmyadmin
…
</Directory>
</VirtualHost>




  เพิ่ม config ในส่วนสีน้ ำเงิน
                          ำ
  $ sudo service apache2 restart
https://pma.domain.com
NameVirtualHost pma.domain.com:443

<VirtualHost pma.domain.com:443>

# Alias /phpmyadmin /usr/share/phpmyadmin
DocumentRoot /usr/share/phpmyadmin
…
</Directory>
SSLEngine on
SSLCertificateFile    /etc/ssl/certs/ssl­cert­snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl­cert­snakeoil.key

<FilesMatch ".(cgi|shtml|phtml|php)$">
       SSLOptions +StdEnvVars
</FilesMatch>

</VirtualHost>

More Related Content

What's hot

Docker 101 for developer
Docker 101 for developerDocker 101 for developer
Docker 101 for developer
Arnon Kijlardphon
 
Docker 1st time
Docker 1st timeDocker 1st time
Docker 1st time
Ongart Visarnpat
 
Proxy fc4 web
Proxy fc4 webProxy fc4 web
Proxy fc4 web
Green Jb
 
Php พื้นฐาน ตอนที่3
Php พื้นฐาน ตอนที่3Php พื้นฐาน ตอนที่3
Php พื้นฐาน ตอนที่3
ปรัชญาทวี พงพยัคฆ์
 
คู่มือการติดตั้ง Cent os
คู่มือการติดตั้ง  Cent osคู่มือการติดตั้ง  Cent os
คู่มือการติดตั้ง Cent osPacharin Ngowpradit
 
VBoxManage tutorial
VBoxManage tutorialVBoxManage tutorial
VBoxManage tutorial
Bhuridech Sudsee
 

What's hot (9)

Ch06 bind9
Ch06 bind9Ch06 bind9
Ch06 bind9
 
Docker 101 for developer
Docker 101 for developerDocker 101 for developer
Docker 101 for developer
 
Docker 1st time
Docker 1st timeDocker 1st time
Docker 1st time
 
Ch05 name-services
Ch05 name-servicesCh05 name-services
Ch05 name-services
 
Xampp guide
Xampp guideXampp guide
Xampp guide
 
Proxy fc4 web
Proxy fc4 webProxy fc4 web
Proxy fc4 web
 
Php พื้นฐาน ตอนที่3
Php พื้นฐาน ตอนที่3Php พื้นฐาน ตอนที่3
Php พื้นฐาน ตอนที่3
 
คู่มือการติดตั้ง Cent os
คู่มือการติดตั้ง  Cent osคู่มือการติดตั้ง  Cent os
คู่มือการติดตั้ง Cent os
 
VBoxManage tutorial
VBoxManage tutorialVBoxManage tutorial
VBoxManage tutorial
 

Viewers also liked

CompTIA Linux+
CompTIA Linux+CompTIA Linux+
CompTIA Linux+
Matthew Shellhart
 
Ch17 secure-password
Ch17 secure-passwordCh17 secure-password
Ch17 secure-password
Chatchai Jantaraprim
 
Editors for-linux
Editors for-linuxEditors for-linux
Editors for-linux
Chatchai Jantaraprim
 
Ch01 administrators-tasks
Ch01 administrators-tasksCh01 administrators-tasks
Ch01 administrators-tasks
Chatchai Jantaraprim
 
Learn docker in 90 minutes
Learn docker in 90 minutesLearn docker in 90 minutes
Learn docker in 90 minutes
Larry Cai
 
Shipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with DockerShipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with Docker
Jérôme Petazzoni
 
A Gentle Introduction To Docker And All Things Containers
A Gentle Introduction To Docker And All Things ContainersA Gentle Introduction To Docker And All Things Containers
A Gentle Introduction To Docker And All Things Containers
Jérôme Petazzoni
 
Why Docker
Why DockerWhy Docker
Why Docker
dotCloud
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
dotCloud
 
Docker from A to Z, including Swarm and OCCS
Docker from A to Z, including Swarm and OCCSDocker from A to Z, including Swarm and OCCS
Docker from A to Z, including Swarm and OCCS
Frank Munz
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
LinkedIn
 
The Future of Everything
The Future of EverythingThe Future of Everything
The Future of Everything
Charbel Zeaiter
 

Viewers also liked (14)

CompTIA Linux+
CompTIA Linux+CompTIA Linux+
CompTIA Linux+
 
Ch17 secure-password
Ch17 secure-passwordCh17 secure-password
Ch17 secure-password
 
Editors for-linux
Editors for-linuxEditors for-linux
Editors for-linux
 
Ch01 administrators-tasks
Ch01 administrators-tasksCh01 administrators-tasks
Ch01 administrators-tasks
 
Virtualbox networking
Virtualbox networkingVirtualbox networking
Virtualbox networking
 
Learn docker in 90 minutes
Learn docker in 90 minutesLearn docker in 90 minutes
Learn docker in 90 minutes
 
Ch09 mail-systems-part2
Ch09 mail-systems-part2Ch09 mail-systems-part2
Ch09 mail-systems-part2
 
Shipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with DockerShipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with Docker
 
A Gentle Introduction To Docker And All Things Containers
A Gentle Introduction To Docker And All Things ContainersA Gentle Introduction To Docker And All Things Containers
A Gentle Introduction To Docker And All Things Containers
 
Why Docker
Why DockerWhy Docker
Why Docker
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 
Docker from A to Z, including Swarm and OCCS
Docker from A to Z, including Swarm and OCCSDocker from A to Z, including Swarm and OCCS
Docker from A to Z, including Swarm and OCCS
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
 
The Future of Everything
The Future of EverythingThe Future of Everything
The Future of Everything
 

Similar to Ch11 web-app

Ch02 administrators-tasks
Ch02 administrators-tasksCh02 administrators-tasks
Ch02 administrators-tasks
Chatchai Jantaraprim
 
เว็บสำเร็จรูป
เว็บสำเร็จรูปเว็บสำเร็จรูป
เว็บสำเร็จรูปniwat
 
Portable Moodle : Moodle & Server2Go
Portable Moodle  : Moodle & Server2GoPortable Moodle  : Moodle & Server2Go
Portable Moodle : Moodle & Server2Go
Boonlert Aroonpiboon
 
NETWORK SERVICEOPENSSH + NTP + SQUID
NETWORK SERVICEOPENSSH + NTP + SQUIDNETWORK SERVICEOPENSSH + NTP + SQUID
NETWORK SERVICEOPENSSH + NTP + SQUID
Ploynatcha Akkaraputtipat
 
Joomla 3.7 Workshop 1 Day
Joomla 3.7 Workshop 1 Day Joomla 3.7 Workshop 1 Day
Joomla 3.7 Workshop 1 Day
Akarawuth Tamrareang
 
php5new
php5newphp5new
การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 05
การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 05การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 05
การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 05
Jenchoke Tachagomain
 
01 ความรู้เกี่ยวกับการ web programming
01 ความรู้เกี่ยวกับการ web programming01 ความรู้เกี่ยวกับการ web programming
01 ความรู้เกี่ยวกับการ web programmingsupatra178
 

Similar to Ch11 web-app (14)

Ch07 bind9-part2
Ch07 bind9-part2Ch07 bind9-part2
Ch07 bind9-part2
 
Ch02 administrators-tasks
Ch02 administrators-tasksCh02 administrators-tasks
Ch02 administrators-tasks
 
Iis7on microsoftwindows2008
Iis7on microsoftwindows2008Iis7on microsoftwindows2008
Iis7on microsoftwindows2008
 
Linux diskless
Linux disklessLinux diskless
Linux diskless
 
Linux diskless
Linux disklessLinux diskless
Linux diskless
 
เว็บสำเร็จรูป
เว็บสำเร็จรูปเว็บสำเร็จรูป
เว็บสำเร็จรูป
 
Cent os
Cent osCent os
Cent os
 
Portable Moodle : Moodle & Server2Go
Portable Moodle  : Moodle & Server2GoPortable Moodle  : Moodle & Server2Go
Portable Moodle : Moodle & Server2Go
 
NETWORK SERVICEOPENSSH + NTP + SQUID
NETWORK SERVICEOPENSSH + NTP + SQUIDNETWORK SERVICEOPENSSH + NTP + SQUID
NETWORK SERVICEOPENSSH + NTP + SQUID
 
Doc1
Doc1Doc1
Doc1
 
Joomla 3.7 Workshop 1 Day
Joomla 3.7 Workshop 1 Day Joomla 3.7 Workshop 1 Day
Joomla 3.7 Workshop 1 Day
 
php5new
php5newphp5new
php5new
 
การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 05
การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 05การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 05
การพัฒนาเอกสารออนไลน์ขั้นสูง Lect 05
 
01 ความรู้เกี่ยวกับการ web programming
01 ความรู้เกี่ยวกับการ web programming01 ความรู้เกี่ยวกับการ web programming
01 ความรู้เกี่ยวกับการ web programming
 

Ch11 web-app

  • 1. Linux Server Admin Web Applications Chatchai J 2013-01-14 2013-01-16
  • 2. Application on Web ● Using Web as User Interface ● Example – Database : phpmyadmin ● php, mysql – Mail : web mail ● roundcube ● squirrelmail – Weblog – blog ● wordpress
  • 3. phpmyadmin ● ติดตั้ง $ sudo apt-get install phpmyadmin ● config – เลือก apache2 เป็ น Web Server – admin password สำำหรับ mysql server (root) – password สำำหรับ phpmyadmin ● LEAVE IT BLANK (phpmyadmin จะ gen random password ให้)
  • 4. phpmyadmin (ต่อ) ● ทดสอบที่ URL http://www.domain.com/phpmyadmin http://172.30.160.xx/phpmyadmin ● login โดยใช้ admin account ของ mysql – login: – password: ● ใช้งำนได้แล้ว!
  • 5. ในกรณีที่มีปัญหำ ➔ apache web server ทำำงำนอย่่หรือเปล่ำ? $ ps uaxw | grep apache ถ้ำไม่ แก้ปัญหำ config ของ apache ก่อน $ sudo apachectl configtest ด่วำมี error ที่ใหนแล้วแก้ไขให้ถ่กต้อง ่   $ sudo apachectl restart
  • 6. ในกรณีที่มีปัญหำ (ต่อ) ➔ เปิ ด webbrowser (firefox, lynx, epiphany, chromium-browser) $ firefox localhost ➔ ควรที่จะใช้งำนได้, ถ้ำไม่ได้ → ยกมือถำม ➔ เปลี่ยนจำก localhost เป็ น ip address * ตรวจสอบให้แน่ใจว่ำ IP address ของเครื่อง VM คืออะไร ก่อนเปิ ด $ firefox http://172.30.160.XX ➔ ควรที่จะใช้งำนได้, ถ้ำไม่ได้ → ยกมือถำม
  • 7. ในกรณีที่มีปัญหำ (ต่อ) ➔ เปิ ดโดยใช้ domain name (www.domain.com)  $ firefox http://www.domain.com ➔ ถ้ำมีปัญหำ ให้ตรวจสอบ DNS $ host ­t a www.domain.com localhost $ host ­t a www.domain.com 172.30.0.85 $ host ­t a www.domain.com lsa­svr.coe.psu.ac.th $ host ­t a www.domain.com ➔ ทุกคำำสั่งควรจะให้คำำตอบเดียวกัน คือ IP Address ของ เครื่อง VM ของคุณในตอนนี้
  • 8. ถ้ำ lookup address แล้วมีปัญหำ ● ไฟล์ /etc/resolv.conf ของ VM (และของ host) จะต้องมีข้อม่ลดังนี้ domain coe.psu.ac.th search coe.psu.ac.th nameserver 172.30.0.85 ● ยกเว้นว่ำ คุณร้่ว่ำมันมีควำมหมำยว่ำอย่ำงไร (ซึ่ งคุณควรจะร้่) และจะใช้วิธีกำรอื่นได้อย่ำงไร ● VM จะต้องส่ง notification ไปยัง lsa-svr.coe.psu.ac.th เพื่อ register domain ของตัวเองให้ lsa-svr ร้่จัก – update serial ใน ZONE file แล้วใช้ rndc reload
  • 9. ปั ญหำของ DNS $ host ­t a www.domain.com localhost ● ถ้ำไม่สำมำรถ resolve ได้แสดงว่ำ named server บน VM มีปัญหำ ● ตรวจสอบว่ำ named run อย่่หรือเปล่ำ? $ ps auxw | grep named ● ถ้ำไม่มีให้ start bind9 $ sudo service bind9 start
  • 10. ปั ญหำของ DNS (ต่อ) ● ถ้ำ start named ไม่ได้ ให้ตรวจสอบ config ของ named $ named­checkconf $ named­checkconf ­z ● ทั้งสองคำำสั่ง จะต้องไม่มี error ถ้ำมี ให้แก้ไขให้ถ่กต้อง ถ้ำยังแก้ไม่ได้ → ยกมือถำม $ sudo service bind9 restart $ sudo rndc reload ● แล้วตรวจสอบ log ใน /var/log/syslog $ sudo grep named /var/log/syslog | tail ­25 ● จะต้องมีข้อควำม “running” หรือ “reload configuration succeeded” ● มีข้อควำม “zone domain.com/IN: sending notified (serial xxxxxxxxxx)”
  • 11. ปั ญหำของ DNS (ต่อ) $ host ­t a www.domain.com 172.30.0.85 $ host ­t a www.domain.com lsa­svr.coe.psu.ac.th ● ถ้ำไม่สำมำรถ resolve ได้แสดงว่ำ ข้อม่ลของ zone มีปัญหำ ● ใน zone ไฟล์ /var/cache/bind/master/domain.com จะต้องมี – record ของ NS 2 record $ORIGIN domain.com.                 IN NS lsa­svr.coe.psu.ac.th.                 IN NS ns.domain.com. – Note: บรรทัด $ORIGIN มีควำมสำำคัญ – และมี A record ของ ns.domain.com ซึ่งมี IP Address เป็ นของ VM ในขณะนี้ ns              IN A 172.30.160.xx
  • 12. ปั ญหำของ DNS (ต่อ) ● ทุกครั้งที่แก้ไข zone ไฟล์ ให้ update serial ของ SOA เสมอ ● หลังจำกแก้ไขเสร็จ reload config แล้ว ตรวจสอบอีกครั้ง ● ถ้ำยังใช้งำนไม่ได้ → ยกมือถำม
  • 13. กลับมำที่ www ● ถึงตอนนี้ควรทีจะใช้งำน ่ $ firefox http://www.domain.com ● จำก VM (และจำก host ถ้ำ nameserver เป็ น 172.30.0.85) ได้แล้ว ● ต่อไปเป็ นกำรเข้ำถึง phpmyadmin $ firefox http://www.domain.com/phpmyadmin
  • 14. phpmyadmin ● ถ้ำเข้ำถึง http://www.domain.com ได้ แต่ http://www.domain.com/phpmyadmin ยังไม่ได้ ● จะเป็ นปั ญหำที่ config ของ phpmyadmin ● ตรวจสอบด่ว่ำมีไฟล์ /etc/apache2/conf.d/phpmyadmin.conf หรือเปล่ำ $ ls ­l /etc/apache2/conf.d | grep phpmyadmin ● ควรจะมีไฟล์ config ใน /etc/phpmyadmin/apache.conf อย่แล้ว ่ $ ls ­l /etc/phpmyadmin/apache.conf – ถ้ำไม่มี ให้ตดตั้ง phpmyadmin ใหม่ ิ
  • 15. phpmyadmin ● สร้ำง link จำก /etc/phpmyadmin/apache.conf ไป ไว้ใน /etc/apache2/conf.d $ cd /etc/apache2/conf.d $ sudo ln ­sf /etc/phpmyadmin/apache.conf phpmyadmin.conf ● restart apache2 ใหม่ ทุกครั้งหลังจำกมีกำรเปลี่ยนแปลง config $ sudo service apache2 restart
  • 16. phpmyadmin ● ติดตั้ง phpmyadmin ใหม่ $ sudo apt­get purge phpmyadmin $ sudo rm ­rvf /etc/phpmyadmin $ sudo apt­get install phpmyadmin
  • 17. ปั ญหำ!!! ● ผ่ำนทำง web interface ● ส่งข้อม่ลแบบ plain text ● login/password สำำหรับ database ซึ่งสำมำรถ แก้ไขข้อม่ลใดๆ ก็ได้ในฐำนข้อม่ลทั้งหมด ● YOU SHOULD NOT DOING SOMETHING LIKE THAT! ● วิธีกำรแก้ไข เข้ำรหัสกำรติดต่อ โดยใช้ https
  • 18. เข้ำรหัส HTTP ● ใช้ https ● ssl เป็ น module ของ apache2 ● สำมำรถ enable โดยใช้ “a2enmod ssl” $ sudo a2enmod ssl $ sudo service apache2 restart
  • 19. เข้ำรหัส HTTP (ต่อ) ● config ของ apache สำำหรับ ssl แยกออกมำจำก default ซึ่งไม่ได้เข้ำรหัส ● ด่ไฟล์ใน /etc/apache2/sites-available และ /etc/sites- enabled ● สำมำรถ enable โดยใช้คำำสั่ง a2ensite $ sudo a2ensite default­ssl $ sudo service apache2 restart
  • 20. https connection ● สำมำรถ connect โดยใช้ https://www.domain.com – จะต้อง trust key ที่สร้ำงขึ้นมำก่อน เพรำะเป็ นแบบ self-signed ● ใช้งำนได้แล้ว? https://www.domain.com/phpmyadmin แล้ว http://www.domain.com/phpmyadmin ล่ะ?
  • 21. อันตรำยจำก phpmyadmin ● มี zombie bot จำำนวนมำกใช้วิธีกำร bruteforce attack อย่่ จำำนวนมำก ● ตัวอย่ำงบน publish-paper ● กำรป้ องกัน – mysql administrator password MUST secure – update/upgrade phpmyadmin อย่่เสมอ – ซ่อนมันไว้หลัง virtualhost อื่น
  • 22. เพิ่ม name ต่อไปนี้ใน Zone file ● shell ● webmail ● pma (phpmyadmin) ● webmin ● blog pma IN A 172.30.160.xxx shell IN A 172.30.160.xxx ... ● เพื่อให้สำมำรถใช้ช่ อ pma.domain.com (และอื่ นๆ) ได้ ื
  • 23. virtualhost config ● เรำจะใช้ https://pma.domain.com สำำหรับกำรเข้ำถึง phpmyadmin เท่ำนั้น ไม่สำมำรถเข้ำจำกทำงอื่นได้ ● ด่ตัวอย่ำงกำร config virtualhost ของ https://www.domain.com จำก /etc/apache2/sites-available/default-ssl
  • 24. virtual host ● เริ่มจำก http://pma.mydomain.com ให้เข้ำถึง phpmyadmin ● ใช้ NameVirtualHost และ VirtualHost ● ในไฟล์ /etc/phpmyadmin/apache.conf