Setting Up a Local YUM Repository server with Nginx Using RHEL ISO
Overview
First iso image file should be mounted as a seperate filesystem to access the package files. Then Createrepo and Nginx server should be installed and enabled. Then the Appstream and BaseOS directory have to be mounted on nginx's filepath. Firewall rules needed to be configured, so that Nginx can serve those repos. After that on that filepath "createrepo" need to be executed, this will make those directories package repository. Test this by configuring local yum configuration inside "/etc/yum.repos.d" directory.
Requirements
- RHEL ISO image (e.g., rhel9.iso) 
- createrepo package 
- Nginx web server 
Step 1: Mounting iso image as seperate filesystemto to access the package files
i)
mount -o loop /rhel9.iso /media"-o" and "loop" are used to make this iso as file system and this will mount the files in /media
ii)
mkdir /packageshere Appstream and BaseOS directory need to be copied untill nginx is available.
iii)
cp -ar /media/Appstream /packagesiv)
cp -ar /media/BaseOS /packagesCoping the Appstream and BaseOS to /packages. "-ar" is used to copy archive and recursive files also Now you can ls inside /packages and also inside /packages/Appstream , /packages/BaseOS to verify.
Step 2: Installing Createrepo and Nginx package
i)
yum install createrepoii)
yum install nginxiii)
systemctl enable --now nginxTo enable nginx, you can verify with
systemctl status nginxStep 3: Moving files inside nginx's directory
i)
mkdir -p /usr/share/nginx/html/repo/appstream"/usr/share/nginx/html/" till this already created.
ii)
mkdir -p /usr/share/nginx/html/repo/baseosNeed to create /repo and inside /repo , /appstream and /baseos need to be created
Step 4: Creating Repository Metadata
i)
createrepo /usr/share/nginx/html/repo/appstreamii)
createrepo /usr/share/nginx/html/repo/baseosStep 5: Set Nginx Permissions and SELinux Context
i)
chown -R nginx:nginx /usr/share/nginx/html/repoIf SELinux is installed then also execute this
ii)
chcon -R -t httpd_sys_content_t /usr/share/nginx/html/repoStep 6: Opening http port in system's firewall to make repos accessable
i)
firewall-cmd --add-service=http -permanentii)
firewall-cmd --reloadStep 7: Testing this repos inside the system itself which will fetch from localhost
i)
cd /etc/yum.repos.dhere either "local.repo" file can be configured or this repo should be disabled and a new ".repo" file should be created, do vi and paste the below inside the ".repo" file
[InternalRepo_Appstream]
name=Internal_Repository_Appstream
baseurl=http://SYSTEM-IP/repo/appstream
enabled=1
gpgcheck=0
[InternalRepo_BaseOS]
name=Internal_Repository_BaseOS
baseurl=http://SYSTEM-IP/repo/baseos
enabled=1
gpgcheck=0ii)
yum clean allTo clean the cache
iii)
yum repolistTo view the new repolist
iv)
yum install <PACKAGE-NAME>To install the package
Step 8: Configure Client Machines
After successfully testing inside the satelite server itself with localhost now clients can be configured. Paste the following inside "/etc/yum.repos.d" either by creating new ".repo" file or replace the contents inside "local.repo".
[InternalRepo_Appstream]
name=Internal_Repository_Appstream
baseurl=http://SERVER-IP/repo/appstream
enabled=1
gpgcheck=0
[InternalRepo_BaseOS]
name=Internal_Repository_BaseOS
baseurl=http://SERVER-IP/repo/baseos
enabled=1
gpgcheck=0**But ensure other repos should be disabled, like this
[Local_repo]
name=Local_Repository
baseurl=/repo_path
enabled=0                    This should be "0"
gpgcheck=0✅ Done!
Your local YUM satellite server is now configured and accessible to clients within your network via HTTP. This setup is especially useful for offline environments or restricted networks.