File tree Expand file tree Collapse file tree 4 files changed +39
-1
lines changed Expand file tree Collapse file tree 4 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ COPY files/ecr.ini /etc/supervisor.d/ecr.ini
1313COPY files/root /etc/crontabs/root
1414
1515COPY files/nginx.conf /usr/local/openresty/nginx/conf/nginx.conf
16+ COPY files/ssl.conf /usr/local/openresty/nginx/conf/ssl.conf
1617
1718ENV PORT 5000
1819
Original file line number Diff line number Diff line change @@ -18,11 +18,20 @@ http {
1818 # this is necessary for us to be able to disable request buffering in all cases
1919 proxy_http_version 1.1;
2020
21+ #SSLCONFIG
22+
2123 # will run before forking out nginx worker processes
2224 init_by_lua_block { require "cjson" }
2325
26+ #https://docs.docker.com/registry/recipes/nginx/#setting-things-up
27+ map $upstream_http_docker_distribution_api_version $docker_distribution_api_version {
28+ '' 'registry/2.0' ;
29+ }
30+
2431 server {
25- listen PORT default_server;
32+ listen LISTEN default_server;
33+
34+ #AUTHCONFIG
2635
2736 # Cache
2837 add_header X-Cache-Status $upstream_cache_status ;
5059 http_500 http_502 http_503 http_504;
5160 proxy_cache_lock on;
5261
62+ add_header 'Docker-Distribution-Api-Version' $docker_distribution_api_version always;
5363 add_header "Access-Control-Allow-Origin" "*" ;
5464
5565 location / {
Original file line number Diff line number Diff line change 1+ ssl_certificate_key REGISTRY_HTTP_TLS_KEY;
2+ ssl_certificate REGISTRY_HTTP_TLS_CERTIFICATE;
3+
4+ ssl_protocols TLSv1.2;
5+ 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';
6+ ssl_prefer_server_ciphers on;
7+
8+ add_header Strict-Transport-Security max-age=31536000;
9+
Original file line number Diff line number Diff line change @@ -36,11 +36,29 @@ echo Using cache max size $CACHE_MAX_SIZE
3636
3737CONFIG=/usr/local/openresty/nginx/conf/nginx.conf
3838
39+ ENABLESSL=' '
40+ SSLINCLUDE=' '
41+ SSLCONFIG=/usr/local/openresty/nginx/conf/ssl.conf
42+ if [ ! -z " $REGISTRY_HTTP_TLS_CERTIFICATE " ] && [ ! -z " $REGISTRY_HTTP_TLS_KEY " ]; then
43+ sed -i -e s! REGISTRY_HTTP_TLS_CERTIFICATE! " $REGISTRY_HTTP_TLS_CERTIFICATE " ! g $SSLCONFIG
44+ sed -i -e s! REGISTRY_HTTP_TLS_KEY! " $REGISTRY_HTTP_TLS_KEY " ! g $SSLCONFIG
45+ ENABLESSL=' ssl'
46+ SSLINCLUDE=" include $SSLCONFIG ;"
47+ fi
48+
49+ AUTHCONFIG=' '
50+ if [ ! -z " $REGISTRY_AUTH_HTPASSWD_PATH " ] && [ ! -z " $REGISTRY_AUTH_HTPASSWD_REALM " ]; then
51+ AUTHCONFIG=" auth_basic ${REGISTRY_AUTH_HTPASSWD_REALM} ;\n auth_basic_user_file ${REGISTRY_AUTH_HTPASSWD_PATH} ;"
52+ fi
53+
3954# Update nginx config
4055sed -i -e s! UPSTREAM! " $UPSTREAM " ! g $CONFIG
56+ sed -i -e s! LISTEN! " $PORT $ENABLESSL " ! g $CONFIG
4157sed -i -e s! PORT! " $PORT " ! g $CONFIG
4258sed -i -e s! RESOLVER! " $RESOLVER " ! g $CONFIG
4359sed -i -e s! CACHE_MAX_SIZE! " $CACHE_MAX_SIZE " ! g $CONFIG
60+ sed -i -e s! # SSLCONFIG!"$SSLINCLUDE"!g $CONFIG
61+ sed -i -e s! # AUTHCONFIG!"$AUTHCONFIG"!g $CONFIG
4462
4563# setup ~/.aws directory
4664AWS_FOLDER=' /root/.aws'
You can’t perform that action at this time.
0 commit comments