How to Set Up a Distribution Mirror

Systems can be configured to distribute packages and provide updates to client systems within a local network without the need for clients to access the public servers through the Internet.

You can select any method to provide access to the local repositories in the mirror server. This task uses HTTP as an example.

  1. Ensure that the latest version of the yum-utils is installed on the system.
    sudo dnf install -y yum-utils
  2. Install the Apache HTTP server.
    sudo dnf install -y httpd
  3. Create a base directory for the local repositories, for example:
    sudo mkdir -p /var/www/html/yum
  4. If you created a dedicated file system for the mirror, mount that file system to the base directory. For example, edit the /etc/fstab with the details of the file system mounted on the /var/www/html/yum, then run the following:
    sudo mount device-path
    In the previous example, device-path is the path to the device. For example:
    sudo mount /dev/sda
  5. Check if SELinux is enabled. For example, the following command shows that SELinux is enabled and set to Enforcing:
    sestatus
    SELinux status:                 enabled
    ...
    Current mode:                   enforcing
    Mode from config file:          enforcing
    ...
  6. If SELinux is enabled in enforcing mode and you have mounted another file system on /var/www/html/yum/ , do the following steps:
    1. Define the default file type of the repository root directory hierarchy as httpd_sys_content_t. For example, if the base directory is /var/www/html/yum/, then run the following:
      sudo /usr/sbin/semanage fcontext -a -t httpd_sys_content_t "/var/www/html/yum(/.*)?"
    2. Apply the file type to the entire repository.
      sudo /sbin/restorecon -R -v /var/www/html/yum/
  7. Edit the HTTP server configuration file, /etc/httpd/conf/httpd.conf, as follows:
    1. Specify the resolvable domain name or the IP address of the server in the argument to ServerName.
      ServerName system-mirror:80
    2. Verify that in the <Directory "/var/www/html"> section, the setting of the Options directive specifies Indexes and FollowSymLinks, for example:
      Options Indexes FollowSymLinks
      With this setting, you can browse the directory hierarchy.
  8. Start the HTTP server and configure it to start after a reboot.
    sudo systemctl start httpd
    sudo systemctl enable httpd
  9. If you enabled a firewall on the system, configure it to enable incoming HTTP connection requests on TCP port 80.
    sudo firewall-cmd --add-service=http
    sudo firewall-cmd --permanent --add-service=http
  10. Choose how you want the local mirror to function to serve clients in the local network: