

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 투명 프록시 서버에서 CodeBuild 실행
<a name="run-codebuild-in-transparent-proxy-server"></a>

 투명한 프록시 서버에서 AWS CodeBuild 를 실행하려면 상호 작용하는 웹 사이트 및 도메인에 액세스할 수 있도록 프록시 서버를 구성해야 합니다.

**Topics**
+ [Squid를 투명 프록시 서버로 구성](#use-proxy-server-transparent-squid-configure)
+ [CodeBuild 프로젝트 생성](#use-proxy-server-transparent-create-acb-project)

## Squid를 투명 프록시 서버로 구성
<a name="use-proxy-server-transparent-squid-configure"></a>

 프록시 서버를 투명으로 구성하려면 액세스하려는 도메인 및 웹 사이트에 대한 액세스 권한을 부여해야 합니다. 투명한 프록시 서버 AWS CodeBuild 로를 실행하려면에 대한 액세스 권한을 부여해야 합니다`amazonaws.com`. 또한 CodeBuild가 사용하는 다른 웹 사이트에 대해서도 액세스 권한을 부여해야 합니다. 이러한 웹 사이트는 CodeBuild 프로젝트를 생성하는 방식에 따라 달라집니다. 예를 들어 GitHub, Bitbucket, Yum, Maven 같은 리포지토리용 웹 사이트입니다. Squid에 특정 도메인 및 웹 사이트에 대한 액세스 권한을 부여하려면 다음과 같은 명령을 사용하여 `squid.conf` 파일을 업데이트합니다. 이 샘플 명령은 `amazonaws.com`, `github.com` 및 `bitbucket.com`에 대한 액세스 권한을 부여합니다. 이 샘플을 편집하여 다른 웹 사이트에 대한 액세스 권한을 부여할 수 있습니다.

```
cat | sudo tee /etc/squid/squid.conf ≪EOF
visible_hostname squid
#Handling HTTP requests
http_port 3129 intercept
acl allowed_http_sites dstdomain .amazonaws.com
#acl allowed_http_sites dstdomain domain_name [uncomment this line to add another domain]
http_access allow allowed_http_sites
#Handling HTTPS requests
https_port 3130 cert=/etc/squid/ssl/squid.pem ssl-bump intercept
acl SSL_port port 443
http_access allow SSL_port
acl allowed_https_sites ssl::server_name .amazonaws.com
acl allowed_https_sites ssl::server_name .github.com
acl allowed_https_sites ssl::server_name .bitbucket.com
#acl allowed_https_sites ssl::server_name [uncomment this line to add another website]
acl step1 at_step SslBump1
acl step2 at_step SslBump2
acl step3 at_step SslBump3
ssl_bump peek step1 all
ssl_bump peek step2 allowed_https_sites
ssl_bump splice step3 allowed_https_sites
ssl_bump terminate step2 all
http_access deny all
EOF
```

 프라이빗 서브넷에 있는 인스턴스에서 오는 수신 요청은 Squid 포트로 리디렉션해야 합니다. Squid는 HTTP 트래픽의 경우 포트 3129(80이 아님)에서 수신 대기하고, HTTPS 트래픽의 경우 포트 3130(443이 아님)에서 수신 대기합니다. **iptables** 명령을 사용하여 트래픽을 라우팅합니다.

```
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3129
sudo iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 3130
sudo service iptables save
sudo service squid start
```

## CodeBuild 프로젝트 생성
<a name="use-proxy-server-transparent-create-acb-project"></a>

 프록시 서버를 구성한 후에는 추가 구성 없이 프라이빗 서브넷 AWS CodeBuild 에서와 함께 사용할 수 있습니다. 모든 HTTP 및 HTTPS 요청이 퍼블릭 프록시 서버를 통과합니다. 다음 명령을 사용하여 Squid 프록시 액세스 로그를 확인합니다.

```
sudo tail -f /var/log/squid/access.log
```