Skip to content

Commit 721e894

Browse files
fix(proxy): enable https
1 parent 75cba4f commit 721e894

File tree

4 files changed

+39
-13
lines changed

4 files changed

+39
-13
lines changed

.markdownlint.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Default state for all rules
2+
default: true
3+
4+
# MD013/line-length - Line length
5+
MD013:
6+
line_length: 200

README.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
# Build with bake
1+
# Docker registry proxy
2+
3+
## Build with bake
4+
25
```bash
36
docker buildx bake --file docker-bake.hcl
47
```
58

6-
# Create .env file
9+
## Create .env file
10+
711
```bash
812
cp .env.sample .env
913
vim .env
1014
```
1115

12-
# Run with docker
16+
## Run with docker
17+
1318
```bash
1419
docker run --name openresty_docker_registry_proxy \
1520
--rm -it \
@@ -20,28 +25,33 @@ docker run --name openresty_docker_registry_proxy \
2025
docker-registry-proxy-cache:latest
2126
```
2227

23-
# Run with docker compose
28+
## Run with docker compose
29+
2430
```bash
2531
docker compose up
2632
```
2733

2834
The `HTPASSWD` environment variable activates basic authentication. In this example, we define two users:
29-
* user1:user1
30-
* user2:user2
35+
36+
* user1:password1
37+
* user2:password2
3138

3239
The `HTPASSWD_DELIMITER` environment variable can be used to specify a custom delimiter. By default, a `space` is used.
3340

3441
By default, `generate-certificate.sh` generates a self-signed certificate. You can override this by mounting a volume with your own certificates at `/certs`.
42+
3543
* server.crt
3644
* server.key
45+
* proxy_server.crt
46+
* proxy_server.key
47+
48+
## Configure docker to use a proxy
3749

38-
# Configure docker to use a proxy
3950
```json
4051
{
4152
...
4253
"proxies": {
43-
"http-proxy": "http://user1:[email protected]:3128",
44-
"https-proxy": "http://user1:[email protected]:3128"
54+
"https-proxy": "https://user1:[email protected]:3128"
4555
},
4656
"insecure-registries" : ["own-registry.sample.com:443"]
4757
}

generate-certificate.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,12 @@ if [ ! -f /certs/server.crt ]; then
88
-subj "/C=FR/ST=Grand-Est/L=Strasbourg/O=Scalingo/OU=IT Department/CN=scalingo.com"
99
openssl x509 -req -days 365 -in /certs/server.csr -signkey /certs/server.key -out /certs/server.crt
1010
fi
11+
12+
if [ ! -f /certs/proxy_server.crt ]; then
13+
openssl genrsa -des3 -passout pass:x -out /certs/proxy_server.pass.key 2048
14+
openssl rsa -passin pass:x -in /certs/proxy_server.pass.key -out /certs/proxy_server.key
15+
rm /certs/proxy_server.pass.key
16+
openssl req -new -key /certs/proxy_server.key -out /certs/proxy_server.csr \
17+
-subj "/C=FR/ST=Grand-Est/L=Strasbourg/O=Scalingo/OU=IT Department/CN=scalingo.com"
18+
openssl x509 -req -days 365 -in /certs/proxy_server.csr -signkey /certs/proxy_server.key -out /certs/proxy_server.crt
19+
fi

nginx.conf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,7 @@ http {
151151

152152
# The proxy director layer, listens on 3128
153153
server {
154-
listen 3128;
155-
listen [::]:3128;
154+
listen 3128 ssl;
156155
server_name proxy_director_;
157156

158157
# dont log the CONNECT proxy.
@@ -162,6 +161,9 @@ http {
162161

163162
include /opt/openresty/nginx/conf/htpasswd.conf;
164163

164+
ssl_certificate /certs/proxy_server.crt;
165+
ssl_certificate_key /certs/proxy_server.key;
166+
165167
proxy_connect;
166168
proxy_connect_allow all;
167169
proxy_connect_address $interceptedHost;
@@ -182,8 +184,7 @@ http {
182184
# The caching layer
183185
server {
184186
# Listen on both 8080 and 8443, for all hostnames.
185-
listen 8080 default_server;
186-
include /opt/openresty/nginx/conf/caching.layer.listen;
187+
listen 8443 ssl default_server;
187188
server_name proxy_caching_;
188189

189190
# Do some tweaked logging.

0 commit comments

Comments
 (0)