In the architecture of cloud services, multiple network planes are generally deployed, and the management plane is usually in the intranet environment, accessible through a jump server or VPN technology. This brings significant inconvenience to the installation, upgrade, or system upgrade of applications for the infrastructure of the server. Today, I will introduce a simple method to build a self-built Linux private repository.
Before we begin, you need to prepare a virtual host with dual network cards, or a physical host will work as well. The host should run the Linux operating system; here, we'll use CentOS 7.9 as an example. If you are using a Debian-based Linux system, just replace the commands with
apt commands; the principle is exactly the same.
Once the system is installed, connect one network card to the external network and another to the intranet, complete the relevant configurations and tests. Now let's officially start building the private repository.
sudo yum install -y nginx
This is a basic operation, and installing Nginx may require additional steps, such as installing the EPEL repository. If you encounter any issues installing Nginx, please search online for related tutorials.
Configuring Nginx is straightforward. Just add three lines under the
autoindex on; # Add this line
autoindex_exact_size on; # Add this line
autoindex_localtime on; # Add this line
listen 80; # Listening port
Then restart Nginx:
sudo systemctl restart nginx
This directory is configured in the /etc/nginx/nginx.conf file from the previous step. Here, we create it in the default working directory of Nginx:
mkdir -p /usr/share/nginx/html/rsync/
You can download applications individually or synchronize downloads in batches.
As an example, let's download haproxy:
mkdir -p /usr/share/nginx/html/rsync/haproxy
sudo yum -y install --downloadonly --downloaddir=/usr/share/nginx/html/rsync/haproxy/ haproxy
Note: This method downloads only applications that have not been installed on the local machine before. If you try to download an application that has been previously installed, such as nginx, you will get nothing.
Here we use the EPEL repository as an example:
mkdir -p /usr/share/nginx/html/rsync/epel/7/x86_64/
rsync -vrt --bwlimit=3000 --exclude=debug/ rsync://rsync.mirrors.ustc.edu.cn/epel/7/x86_64/ /usr/share/nginx/html/rsync/epel/7/x86_64/
When creating the index for the first time, install
sudo yum install -y createrepo
Create the index; you need to use this command every time you update the content.
After these steps, the sync source is successfully installed. On the intranet host, modify the repo file's
baseurl = http://xxx.xxx.xxx.xxx/rsync
Alternatively, transfer it to the relevant host and install using the following command:
sudo yum install -y http://xxx.xxx.xxx.xxx/rsync/haproxy/haproxy-1.5.18-9.el7_9.1.x86_64.rpm