Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.
Für die Ausführung AWS CodeBuild auf einem expliziten Proxyserver müssen Sie den Proxyserver so konfigurieren, dass er Datenverkehr zu und von externen Websites zulässt oder verweigert, und dann die HTTPS_PROXY
Umgebungsvariablen HTTP_PROXY
und konfigurieren.
Themen
Konfigurieren von Squid als expliziter Proxy-Server
Um Squid als expliziten Proxy-Server zu konfigurieren, müssen Sie die folgenden Änderungen an der Datei /etc/squid/squid.conf
vornehmen:
-
Entfernen Sie die folgenden Standard-ACL-Regeln (ACL = Access Control List, Zugriffskontrollliste).
acl localnet src 10.0.0.0/8 acl localnet src 172.16.0.0/12 acl localnet src 192.168.0.0/16 acl localnet src fc00::/7 acl localnet src fe80::/10
Fügen Sie anstelle der von Ihnen entfernten Standard-ACL-Regeln Folgendes hinzu. Die erste Zeile lässt Anforderungen von Ihrer VPC zu. Die nächsten beiden Zeilen gewähren Ihrem Proxyserver Zugriff auf ein Ziel URLs , das möglicherweise von verwendet wird AWS CodeBuild. Bearbeiten Sie den regulären Ausdruck in der letzten Zeile, um S3-Buckets oder ein CodeCommit Repository in einer AWS Region anzugeben. Zum Beispiel:
-
Wenn Ihre Quelle Amazon S3 ist, verwenden Sie den Befehl, acl download_src dstdom_regex .*s3\.us-west-1\.amazonaws\.com um Zugriff auf S3-Buckets in der
us-west-1
Region zu gewähren. -
Wenn Ihre Quelle ist AWS CodeCommit, verwenden Sie diese
git-codecommit.<
Option, um einer AWS Zulassungsliste eine Region hinzuzufügen.your-region
>.amazonaws.com
acl localnet src 10.1.0.0/16 #Only allow requests from within the VPC acl allowed_sites dstdomain .github.com #Allows to download source from GitHub acl allowed_sites dstdomain .bitbucket.com #Allows to download source from Bitbucket acl download_src dstdom_regex .*\.amazonaws\.com #Allows to download source from Amazon S3 or CodeCommit
-
-
Ersetzen Sie
http_access allow localnet
durch Folgendes:http_access allow localnet allowed_sites http_access allow localnet download_src
-
Wenn Sie möchten, dass Ihr Build Protokolle und Artefakte hochlädt, führen Sie einen der folgenden Schritte aus:
-
Fügen Sie vor der Anweisung
http_access deny all
die folgenden Anweisungen ein. Sie ermöglichen CodeBuild den Zugriff CloudWatch auf Amazon S3. Zugriff auf CloudWatch ist erforderlich, damit CloudWatch Protokolle erstellt CodeBuild werden können. Für das Hochladen von Artefakten und das Amazon S3-Caching ist Zugriff auf Amazon S3 erforderlich.-
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 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
-
Führen Sie nach dem Speichern
squid.conf
den folgenden Befehl aus:sudo iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 3130 sudo service squid restart
-
-
Fügen Sie Ihrer Buildspec-Datei
proxy
hinzu. Weitere Informationen finden Sie unter Syntax der Build-Spezifikation.version: 0.2 proxy: upload-artifacts: yes logs: yes phases: build: commands: - command
-
Anmerkung
Wenn Sie einen RequestError Timeout-Fehler erhalten, finden Sie weitere Informationen unter RequestError Timeout-Fehler bei der Ausführung auf CodeBuild einem Proxyserver.
Weitere Informationen finden Sie unter Expliziter Proxy-Server – squid.conf-Beispieldatei an späterer Stelle in diesem Thema.
Erstellen eines Projekts ( CodeBuild)
Um AWS CodeBuild mit Ihrem expliziten Proxyserver zu arbeiten, legen Sie für dessen Variablen HTTP_PROXY
und HTTPS_PROXY
Umgebungsvariablen die private IP-Adresse der EC2 Instanz fest, die Sie für Ihren Proxyserver erstellt haben, und Port 3128 auf Projektebene. Die private IP-Adresse sieht folgendermaßen aus: http://
. Weitere Informationen erhalten Sie unter Erstellen Sie ein Build-Projekt in AWS CodeBuild und Ändern Sie die Build-Projekteinstellungen in AWS CodeBuild.your-ec2-private-ip-address
:3128
Verwenden Sie den folgenden Befehl, um das Zugriffsprotokoll des Squid-Proxys anzuzeigen:
sudo tail -f /var/log/squid/access.log
Expliziter Proxy-Server – squid.conf
-Beispieldatei
Im Folgenden sehen Sie ein Beispiel für eine squid.conf
-Datei, die für einen expliziten Proxy-Server konfiguriert wurde.
acl localnet src 10.0.0.0/16 #Only allow requests from within the VPC
# add all URLS to be whitelisted for download source and commands to be run in build environment
acl allowed_sites dstdomain .github.com #Allows to download source from github
acl allowed_sites dstdomain .bitbucket.com #Allows to download source from bitbucket
acl allowed_sites dstdomain ppa.launchpad.net #Allows to run apt-get in build environment
acl download_src dstdom_regex .*\.amazonaws\.com #Allows to download source from S3 or CodeCommit
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
#
# Recommended minimum Access Permission configuration:
#
# Deny requests to certain unsafe ports
http_access deny !Safe_ports
# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports
# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager
# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost
#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet allowed_sites
http_access allow localnet download_src
http_access allow localhost
# Add this for CodeBuild to access CWL end point, caching and upload artifacts S3 bucket end point
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 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
# And finally deny all other access to this proxy
http_access deny all
# Squid normally listens to port 3128
http_port 3128
# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /var/spool/squid 100 16 256
# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid
#
# Add any of your own refresh_pattern entries above these.
#
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320