الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

معمل 22.1RHCSA 10, الفصل 22

Make a web server work with SELinux

المستوى
متوسط
40 دقيقة
الأجهزة
server1
الحالة
لم يبدأ

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

الهدف

Serve web pages from a non-standard folder and port, and from user home folders — with SELinux enforcing the whole time.

قبل أن تبدأ

المهام

  1. Change the DocumentRoot of Apache to /web with an index.html that says "selinux lab". Make it work with the right SELinux label (permanent).
  2. Make Apache also listen on port 1001. Fix SELinux and the firewall.
  3. Create /home/student/public_html/index.html with the text "home page". Enable userdir in Apache (UserDir public_html in /etc/httpd/conf.d/userdir.conf) and set the SELinux boolean that allows home folders (permanent). Set the permissions so apache can read the file.
  4. Move a file from /root into /web with mv. Show that the web page for it fails, then fix the label.
  5. Reboot and check that everything still works in enforcing mode.

تحقّق من عملك

curl http://localhost/
curl http://localhost:1001/
curl http://localhost/~student/
getenforce; getsebool httpd_enable_homedirs
ls -Zd /web /web/*
  • All three curl commands show the page text.
  • getenforce = Enforcing, the boolean is on, /web has httpd_sys_content_t.

تلميحات

اعرض التلميحات

الحل

اعرض الحل
  1. New DocumentRoot.
    mkdir /web; echo "selinux lab" > /web/index.html
    sed -i 's|^DocumentRoot.*|DocumentRoot "/web"|; s|<Directory "/var/www/html">|<Directory "/web">|' /etc/httpd/conf/httpd.conf
    semanage fcontext -a -t httpd_sys_content_t "/web(/.*)?"
    restorecon -Rv /web
    systemctl restart httpd
  2. Port 1001.
    echo "Listen 1001" > /etc/httpd/conf.d/port1001.conf
    semanage port -a -t http_port_t -p tcp 1001
    firewall-cmd --add-port=1001/tcp --permanent; firewall-cmd --reload
    systemctl restart httpd
  3. User home pages.
    sed -i 's/^\s*UserDir disabled/#UserDir disabled/; s/^\s*#UserDir public_html/UserDir public_html/' /etc/httpd/conf.d/userdir.conf
    mkdir /home/student/public_html; echo "home page" > /home/student/public_html/index.html
    chown -R student: /home/student/public_html
    chmod 711 /home/student; chmod 755 /home/student/public_html
    setsebool -P httpd_enable_homedirs on
    systemctl restart httpd
  4. The mv problem.
    echo "moved" > /root/moved.html; mv /root/moved.html /web/
    curl -s -o /dev/null -w '%{http_code}\n' http://localhost/moved.html
    403
    restorecon -v /web/moved.html
  5. Reboot and test again.
    systemctl reboot

ملاحظاتي

لا توجد ملاحظات بعد.

دروس هذا المعمل

الأوامر في هذا المعمل