DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • AWS CodeCommit and GitKraken Basics: Essential Skills for Every Developer
  • Keep Your Application Secrets Secret
  • How to Install VPN on Linux?
  • Build a GitHub Slack Bot With AWS Bedrock and MCP, Part 2

Trending

  • How to Submit a Post to DZone
  • 7 Technology Waves I’ve Seen in 30 Years of Software — Will AI Be the Next Real Transformation?
  • Implementing Secure API Gateways for Microservices Architecture
  • Getting Started With Agentic Workflows in Java and Quarkus
  1. DZone
  2. Data Engineering
  3. Databases
  4. NGINX Yum Proxy Repository Setup for Amazon Linux EC2

NGINX Yum Proxy Repository Setup for Amazon Linux EC2

This article is talking about the setting yum proxy for Amazon Linux distribution on AWS Cloud. Read on to find out more!

By 
Vikas Agrawal user avatar
Vikas Agrawal
·
Sep. 28, 20 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
11.7K Views

Join the DZone community and get the full member experience.

Join For Free

Introduction

In the organization, direct exposure to download system or application packages is not allowed due to controlled environment and security risk. To avoid the direct download can set a yum proxy for all the Linux and Unix distributions.

There are so many ways to configure yum proxy via NGINX, Nexus, or JFROG. However, this article is talking about the setting yum proxy for Amazon Linux distribution on AWS Cloud. As some artifactory servers do not support to make a yum proxy for the Amazon Linux EC2.

Steps

Few steps need to follow to set yum proxy for Amazon Linux EC2. First, we need to create the yum proxy server with NGINX then need to configure the client to install system or application packages.

On the Server-side —

Shell
 




xxxxxxxxxx
1
44


 
1
###Install NGINX
2
$ sudo amazon-linux-extras install nginx1 -y
3

          
4

          
5
###Start, Enable and check the status of nginx server
6
$ systemctl start nginx
7
$ systemctl enable nginx
8
$ systemctl status nginx
9

          
10

          
11
###Enable port 80 on Security Groups. We enabled it for VPC access, And in such cases ###where access to another VPC you can always make use of VPC peering. Further if you ###require any on-prem machine have access to this repo you can enable internet ###access on Security groups and use the repo's public IP address (Network charges ###will apply here).
12

          
13

          
14
###Install the create repo and utils tool to allow us to use the reposync command.
15
$ sudo yum install createrepo  yum-utils
16

          
17

          
18
###Create a directly where we will store all the rpm files
19
sudo mkdir -p /var/www/html/repos/amzn2-core
20

          
21

          
22
###Sync the amzn2-core repo with the directory we just created
23
$ sudo reposync --repoid=amzn2-core --newest-only --download-metadata --download_path=/var/www/html/repos/amzn2-core
24

          
25

          
26
###Make the amzn2-core directory a repository using the createrepo command
27
$ sudo createrepo -v /var/www/html/repos/amzn2-core
28

          
29

          
30
###Modify nginx configurations to set document root as /var/www/html/repos. (The same ###can be done with apache where in virtualhosts configurations you can set Document ###root to /var/www/html/repos).
31
$ sudo vi /etc/nginx/conf.d/repos.conf 
32
server {
33
        listen   80;
34
        root   /var/www/html/repos;
35
        location / {
36
                index  index.php index.html index.htm;
37
                autoindex on;   #enable listing of directory index
38
                    }
39
        }
40
:wq!
41

          
42

          
43
###Restart the nginx server for the changes to take in effect.
44
sudo systemctl restart nginx



On the Client-side —

Shell
 




xxxxxxxxxx
1
19


 
1
###Create a repo file, e.g.
2
$ sudo vim /etc/yum.repos.d/local.repo
3

          
4
[local_repo]
5
name=amazon local
6
baseurl=XXX.XXX.XXX.XXX/amzn2-core/
7
enabled=1
8
gpgcheck=0
9

          
10
:wq!
11

          
12

          
13
###Disable all other repos.
14

          
15

          
16
Run $ yum update  > to check if all is well.
17

          
18
sudo yum install httpd -y
19
###Package should install from the local repo.



Also can be checked that all the packages have been synched with the NGINX server. Open the browser and enter —

http://XXX.XXX.XXX.XXX/amzn2-core/amzn2-core/

Here all the packages will be displayed as below —

indexes

Keep learning!

“Learning never exhausts the mind.”
― Leonardo da Vinci

AWS Linux (operating system) Repository (version control)

Opinions expressed by DZone contributors are their own.

Related

  • AWS CodeCommit and GitKraken Basics: Essential Skills for Every Developer
  • Keep Your Application Secrets Secret
  • How to Install VPN on Linux?
  • Build a GitHub Slack Bot With AWS Bedrock and MCP, Part 2

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook