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
Newsletter
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?
  • Google Cloud KMS vs. AWS KMS: Java Encryption Guide

Trending

  • DuckDB for Python Developers
  • How Predictive Analytics Became a Key Enabler for the Future of QA
  • Evaluating RAG in Production — What the Numbers Actually Revealed
  • Running TypeSafe AI's Jev Inside Neo4j for Confidence-Aware Sentiment Decisions

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  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
·
Sep. 28, 20 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
11.9K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

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?
  • Google Cloud KMS vs. AWS KMS: Java Encryption Guide

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • 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