-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from eSailors/ssl
Add support for SSL
- Loading branch information
Showing
11 changed files
with
195 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/dev | ||
/*.retry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,64 @@ | ||
aws-ecr-http-proxy | ||
=========== | ||
<p align="left"> | ||
<a href="https://hub.docker.com/r/esailors/aws-ecr-http-proxy/builds" alt="Build"> | ||
<img src="https://img.shields.io/docker/build/esailors/aws-ecr-http-proxy" /></a> | ||
<a href="https://hub.docker.com/r/esailors/aws-ecr-http-proxy" alt="Pulls"> | ||
<img src="https://img.shields.io/docker/pulls/esailors/aws-ecr-http-proxy" /></a> | ||
<a href="https://www.esailors.de" alt="Maintained"> | ||
<img src="https://img.shields.io/maintenance/yes/2019.svg" /></a> | ||
|
||
A very simple nginx proxy that forwards requests to AWS ECR and caches the responses locally. | ||
</p> | ||
|
||
Run it like this, replace UPSTREAM with your target address with following required params: | ||
- `AWS_REGION` | ||
- `AWS_ACCESS_KEY_ID` | ||
- `AWS_SECRET_ACCESS_KEY` | ||
# aws-ecr-http-proxy | ||
|
||
It is also possible to define `CACHE_MAX_SIZE` env to limit maximum cache size on provided volume | ||
A very simple nginx push/pull proxy that forwards requests to AWS ECR and caches the responses locally. | ||
|
||
For example: | ||
### Configuration: | ||
The proxy is packaged in a docker container and can be configured with following environment variables: | ||
|
||
| Environment Variable | Description | Status | Default | | ||
| :---------------------------------: | :--------------------------------------------: | :-------------------------------: | :--------: | | ||
| `AWS_REGION` | AWS Region for AWS ECR | Required | | | ||
| `AWS_ACCESS_KEY_ID` | AWS Account Access Key ID | Required | | | ||
| `AWS_SECRET_ACCESS_KEY` | AWS Account Secret Access Key | Required | | | ||
| `UPSTREAM` | URL for AWS ECR | Required | | | ||
| `RESOLVER` | DNS server to be used by proxy | Required | | | ||
| `PORT` | Port on which proxy listens | Required | | | ||
| `CACHE_MAX_SIZE` | Maximum size for cache volume | Optional | `75g` | | ||
| `CACHE_KEY` | Cache key used for the content by nginx | Optional | `$uri` | | ||
| `ENABLE_SSL` | Used to enable SSL/TLS for proxy | Optional | `false` | | ||
| `REGISTRY_HTTP_TLS_KEY` | Path to TLS key in the container | Required with TLS | | | ||
| `REGISTRY_HTTP_TLS_CERTIFICATE` | Path to TLS cert in the container | Required with TLS | | | ||
|
||
### Example: | ||
|
||
```sh | ||
docker run --rm --name docker-registry-proxy --net=host \ | ||
-v /local-storage/cache:/cache \ | ||
-v /registry/local-storage/cache:/cache \ | ||
-v /registry/certificate.pem:/opt/ssl/certificate.pem | ||
-v /registry/key.pem:/opt/ssl/key.pem | ||
-e PORT=5000 \ | ||
-e RESOLVER=8.8.8.8 \ | ||
-e UPSTREAM=https://XXXXXXXXXX.dkr.ecr.eu-central-1.amazonaws.com \ | ||
-e AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \ | ||
-e AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \ | ||
-e AWS_REGION=${AWS_DEFAULT_REGION} \ | ||
-e CACHE_MAX_SIZE=100g \ | ||
-e ENABLE_SSL=true \ | ||
-e REGISTRY_HTTP_TLS_KEY=/opt/ssl/key.pem \ | ||
-e REGISTRY_HTTP_TLS_CERTIFICATE=/opt/ssl/certificate.pem | ||
esailors/aws-ecr-http-proxy:latest | ||
``` | ||
|
||
If you ran this command on "registry-proxy.example.com" you can now get your images using `docker pull registry-proxy.example.com:5000/repo/image`. | ||
|
||
### Deploying the proxy | ||
Modify the ansible role variables according to your need and run the playbook as follow: | ||
Modify the ansible role [variables](https://github.com/eSailors/aws-ecr-http-proxy/tree/master/roles/docker-registry-proxy/defaults) according to your need and run the playbook as follow: | ||
```sh | ||
ansible-playbook -i hosts playbook-docker-registry-proxy.yaml | ||
``` | ||
The docker registry for project is available [here](https://hub.docker.com/r/esailors/aws-ecr-http-proxy) | ||
In case you want to enable SSL/TLS please replace the SSL certificates with the valid ones in [roles/docker-registry-proxy/files/*.pem](https://github.com/eSailors/aws-ecr-http-proxy/tree/master/roles/docker-registry-proxy/files) | ||
|
||
### Note | ||
The proxy has `HTTP` endpoint so in order to avoid docker client complaining about it either mark the registry host as insecure in your [deamon config](https://docs.docker.com/registry/insecure/) or add [SSL/TLS termination](https://docs.docker.com/registry/recipes/nginx) | ||
### Note on SSL/TLS | ||
The proxy is using `HTTP` (plain text) as default protocol for now. So in order to avoid docker client complaining either: | ||
- (**Recommended**) Enable SSL/TLS using `ENABLE_SSL` configuration. For that you will have to mount your **valid** certificate/key in the container and pass the paths using `REGISTRY_HTTP_TLS_*` variables. | ||
- Mark the registry host as insecure in your client [deamon config](https://docs.docker.com/registry/insecure/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
ssl_certificate_key REGISTRY_HTTP_TLS_KEY; | ||
ssl_certificate REGISTRY_HTTP_TLS_CERTIFICATE; | ||
|
||
ssl_protocols TLSv1.2; | ||
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256'; | ||
ssl_prefer_server_ciphers on; | ||
|
||
add_header Strict-Transport-Security max-age=31536000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[docker-registry-proxy] | ||
registry-proxy.example.com | ||
localhost ansible_connection=local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIFcTCCA1mgAwIBAgIJALWdZASytQRkMA0GCSqGSIb3DQEBCwUAME8xCzAJBgNV | ||
BAYTAkRFMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxFTATBgNVBAoMDGVTYWlsb3Jz | ||
IExURDESMBAGA1UEAwwJbG9jYWxob3N0MB4XDTE5MDkwMjA4NTYzNloXDTI5MDgz | ||
MDA4NTYzNlowTzELMAkGA1UEBhMCREUxFTATBgNVBAcMDERlZmF1bHQgQ2l0eTEV | ||
MBMGA1UECgwMZVNhaWxvcnMgTFREMRIwEAYDVQQDDAlsb2NhbGhvc3QwggIiMA0G | ||
CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICA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IoVXkA9gYNlCwSpZ49DJJ2gTmI+MXolXnlZCvXuR+VsgTsjn96vH | ||
j0AczAZ+g7gD8XTl/K9Z/gcs06DcmMonYrgOGuaFDDiEuBwgABo8gajCFg4xwxi2 | ||
bw7B+opMrOXH9ZGhaoF2eySDGXXgw7TLRqkGXDghZNzWajnGuN7vSaiQfnr0EmW+ | ||
020gJDDUZyc9Ky165SQe3Bfin1cLc2W6mZYmV9lDtUYw80Gth52L9uOiEBIbV6mI | ||
ZBZFyslxQ7IYWOxseoU9xrxzscTtxa+MGs47w6Hzxh38zYPe/I0Yt62yMRtUmJJ7 | ||
ebQZti7qLeW+QOZAruUzei7fpOZOrq8vy4GBUm0pkg8eOVdDaCAQAWMwaGaHH9/5 | ||
q+AvDLjvR6zvJdV2dxA3XsVmcIA45zOA2mZkRrcTWyf5DZ7bDcQvSnd7R4anv3hG | ||
YJXeKyzcI7SWfMxo0hU6p9fv66xYn6x9d5oA/ZU/5XRn1bFL7kuKj7BmB+LcS0BE | ||
XipqaCA= | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIIJQQIBADANBgkqhkiG9w0BAQEFAASCCSswggknAgEAAoICAQCrznLzCWlKJO4f | ||
XD/E8hx4cXUqbd9UVwpcAzWq3xGjC6gettYSp171elDXj23ddDJ1wwOl2U0bjN/D | ||
ceRCl4Tnb3O86fztBwj8xA/stYGvZQqOvEhSfFh85qvDf1niu2uW1Zx4kMemUvNd | ||
hpXsqa9RPSu0Mb0GZeHnCQkuz3KTjUMhQqwomg/6BY4G7tDmCZYsZezGSgAgoa+Q | ||
4vffW+H8S9nuKi8oEXUf9NuJHUTjtdgcVcCihPj54jXAQsqS9JzWSWxDnKxTaOZu | ||
RWEkG+vqGoKEL5+q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+e+pK | ||
1s6vaEk3ZoJA/Sg31t5gJrA+ND6zbuF1QuMIps9oqnwsh3/79jzXP92lI776hf+v | ||
8uH5IsQeFXBScvc4lSh/q4VRsTMGz9zC4tJYUI718QKB/3qNYM4mMf5gn1NIo6dr | ||
j3v8tRqBiAQ2XAIExZr+eAF5dZVZ2RPOFAoalNP5eJQxHDncYlssrCePNqQr4MVn | ||
Yb0rFrgZMDcqVzGZAURJugVFq/BcRUC8DD3j5I1jda5d64Q0dD8KoFpA4KlzhXJz | ||
ze7h6OJ3UXEcmjq32lUbt/+BogP1q42eLh/b31QhXzMgph9SychKyGPkcEaXVrcz | ||
ukm28gs8UqMRwzfPa4ULtI36l14BU6bNGcInO5gMQcav209gNNBG/4i7MXdhPX8h | ||
qphKZmaIl4WIObu+as4kmoZvVVG2zU5yfujEltNXYDm8Ndw2rapTsDYHfvuXbzII | ||
cQKCAQBW3LAfFAkmu1+NJBXYt86rftOF+VSNWkN1/YkPwIMX1y647aVMGMegr7yF | ||
xUh1DSQQAuD2ACzII1ufoUWRrhdCMsgr3o9b0ApCXQwTaaFsZjGIr33bsnqNHW3e | ||
FJEfTrNW5PLTkkEjJQH0N/6W0TRowjpYSpgRz/fpJjdFLmQ1A+RLVoyHCVq/Qhzj | ||
Ywk6hsYjI432aebdFH8pqWl8Hhcq6DW9jAyKkuVnX/p60OZ6tp6cZ75nIj7bdB7W | ||
zcrUs4/igRY8HUwZlQJK5X2D+LWuN1Ag8DBbbjOmqziKDBikV/GmOcuCRgltckrT | ||
UFg2hiaXvnBuMgGHodqIzeQarqKv | ||
-----END PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters