인프런 커뮤니티 질문&답변
private-ec2에서 nginx 설치
작성
·
85
·
수정됨
0
bastion을 통해서 private-ec2 접속했고
sudo apt update && sudo apt install nginx -y
기존에 사용하던 해당 명령어로 nginx 설치 시도했는데 아래와 같은 오류로 설치가 되지 않습니다
2.4강 이전 강의들에서는 모두 위 명령어로 nginx 설치했는데, private-ec2에서는 안되는 이유가 있을까요...?
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/n/nginx/nginx-common_1.24.0-2ubuntu7.1_all.deb Cannot initiate the connection to ap-northeast-2.ec2.archive.ubuntu.com:80 (2406:da12:944:ae01:72e0:79f6:151f:9770). - connect (101: Network is unreachable) Cannot initiate the connection to ap-northeast-2.ec2.archive.ubuntu.com:80 (2406:da12:944:ae00:62b8:7186:4640:999). - connect (101: Network is unreachable) Cannot initiate the connection to ap-northeast-2.ec2.archive.ubuntu.com:80 (2406:da12:944:ae00:c128:62c8:e380:bcd6). - connect (101: Network is unreachable) Cannot initiate the connection to ap-northeast-2.ec2.archive.ubuntu.com:80 (2406:da12:944:ae01:4edb:4945:bb5c:50ab). - connect (101: Network is unreachable) Could not connect to ap-northeast-2.ec2.archive.ubuntu.com:80 (13.124.255.209), connection timed out Could not connect to ap-northeast-2.ec2.archive.ubuntu.com:80 (13.124.245.230), connection timed out Could not connect to ap-northeast-2.ec2.archive.ubuntu.com:80 (52.79.128.16), connection timed out Could not connect to ap-northeast-2.ec2.archive.ubuntu.com:80 (52.78.32.75), connection timed out
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/n/nginx/nginx_1.24.0-2ubuntu7.1_amd64.deb Cannot initiate the connection to ap-northeast-2.ec2.archive.ubuntu.com:80 (2406:da12:944:ae01:72e0:79f6:151f:9770). - connect (101: Network is unreachable) Cannot initiate the connection to ap-northeast-2.ec2.archive.ubuntu.com:80 (2406:da12:944:ae00:62b8:7186:4640:999). - connect (101: Network is unreachable) Cannot initiate the connection to ap-northeast-2.ec2.archive.ubuntu.com:80 (2406:da12:944:ae00:c128:62c8:e380:bcd6). - connect (101: Network is unreachable) Cannot initiate the connection to ap-northeast-2.ec2.archive.ubuntu.com:80 (2406:da12:944:ae01:4edb:4945:bb5c:50ab). - connect (101: Network is unreachable)
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
답변 2
0
안녕하세요! 좋은 질문 감사합니다.
저도 인프런 AI 인턴의 의견에 동의하는데요, 해당 오류 메시지를 보면 apt update && apt install nginx -y명령어가 실패한 이유는 EC2 인스턴스가 외부 네트워크에 접근할 수 없기 때문입니다. 즉, archive.ubuntu.com 또는 security.ubuntu.com 등에 접속하려고 했지만 실패했습니다.
원인을 요약해보자면
해당 EC2 인스턴스는 Private Subnet에 있어서 인터넷으로 나가는 아웃바운드 네트워크가 차단되어 있습니다.
보통은 NAT Gateway 또는 NAT 인스턴스가 없어 인터넷 접근이 불가능한 구조입니다.
따라서
apt는 외부 저장소(레포)에서 패키지를 내려받지 못하고 에러가 발생합니다.
해결하기 위해서는 NAT Gateway를 설정해야 하는데요,
Public Subnet에 NAT Gateway 생성
Route Table에서 Private Subnet의 0.0.0.0/0 트래픽을 NAT Gateway로 라우팅
순서로 진행해주시면 됩니다. 그리고 나서 다시 설치 명령어를 활용해서 nginx를 설치해주세요
sudo apt update && sudo apt install nginx -y0
안녕하세요, 인프런 AI 인턴입니다. 이슬님.
현재 발생한 문제는 네트워크 연결 관련 오류로 보입니다. private-ec2 인스턴스에서 인터넷에 접근할 수 없는 상태인 것 같네요. 이 문제는 주로 NAT Gateway의 설정 문제나 보안 그룹이 외부 트래픽을 허용하지 않아 발생할 수 있습니다.
문제 요약
- Failed to fetch: 패키지를 다운로드하기 위한 네트워크 연결이 원활하지 않음.
- Network is unreachable와 Connection timed out: 네트워크 설정 문제로 인해 외부 인터넷과의 연결이 차단된 상태.
해결 방법
NAT Gateway 설정 확인:
- private-ec2는 기본적으로 외부 인터넷과 직접 연결되지 않으므로, 인터넷에 접근하기 위해 NAT Gateway를 사용해야 합니다.
- NAT Gateway가 public subnet에 위치해 있으며, 올바르게 설정되어 있는지 확인하세요.
- 라우팅 테이블에서 NAT Gateway로 트래픽이 전달되고 있는지 확인하세요.
- private-ec2는 기본적으로 외부 인터넷과 직접 연결되지 않으므로, 인터넷에 접근하기 위해 NAT Gateway를 사용해야 합니다.
보안 그룹 설정 확인:
- EC2 인스턴스에 연결된 보안 그룹이 필요한 아웃바운드 트래픽(특히 포트 80 및 443)을 허용하도록 설정되어 있는지 확인하세요.
- EC2 인스턴스에 연결된 보안 그룹이 필요한 아웃바운드 트래픽(특히 포트 80 및 443)을 허용하도록 설정되어 있는지 확인하세요.
네트워크 ACL 확인:
- subnet에 있는 네트워크 ACL이 트래픽을 허용할 수 있도록 설정되어 있는지 점검해 보세요.
- subnet에 있는 네트워크 ACL이 트래픽을 허용할 수 있도록 설정되어 있는지 점검해 보세요.
관련 문제와 해결법을 다룬 유사한 질문들을 참고하시면, 보다 상세한 설정 방법을 알 수 있습니다. 이 질문의 경우 VPC에서 인터넷 연결 문제 해결 방법 게시물이 도움이 될 수 있습니다.
저는 질문자님의 이해를 돕고자 지식공유자님의 기존 답변을 참고하여 유사한 답변 링크를 추천해드리고 있습니다. 현재 베타 기능으로 답변이 만족스럽지 않을 수 있는 점 양해 부탁드립니다. 🙏 추가적으로 궁금한 점이 있으시면, 이어서 질문해 주세요. 곧 지식공유자께서 답변해 주실 것입니다.





