File tree Expand file tree Collapse file tree 3 files changed +29
-7
lines changed Expand file tree Collapse file tree 3 files changed +29
-7
lines changed Original file line number Diff line number Diff line change @@ -94,5 +94,8 @@ ENV MANIFEST_CACHE_SECONDARY_TIME="60d"
94
94
# In the default config, :latest and other frequently-used tags will get this value.
95
95
ENV MANIFEST_CACHE_DEFAULT_TIME="1h"
96
96
97
+ # Should we allow actions different than pull, default to false.
98
+ ENV ALLOW_PUSH="false"
99
+
97
100
# Did you want a shell? Sorry, the entrypoint never returns, because it runs nginx itself. Use 'docker exec' if you need to mess around internally.
98
101
ENTRYPOINT ["/entrypoint.sh" ]
Original file line number Diff line number Diff line change @@ -121,6 +121,29 @@ echo "Manifest caching config: ---"
121
121
cat /etc/nginx/nginx.manifest.caching.config.conf
122
122
echo " ---"
123
123
124
+ if [[ " a${ALLOW_PUSH} " == " atrue" ]]; then
125
+ cat << EOF > /etc/nginx/conf.d/allowed.methods.conf
126
+ # allow to upload big layers
127
+ client_max_body_size 0;
128
+
129
+ # only cache GET requests
130
+ proxy_cache_methods GET;
131
+ EOF
132
+ else
133
+ cat << EOF > /etc/nginx/conf.d/allowed.methods.conf
134
+ # Block POST/PUT/DELETE. Don't use this proxy for pushing.
135
+ if ($request_method = POST) {
136
+ return 405 "POST method is not allowed";
137
+ }
138
+ if ($request_method = PUT) {
139
+ return 405 "PUT method is not allowed";
140
+ }
141
+ if ($request_method = DELETE) {
142
+ return 405 "DELETE method is not allowed";
143
+ }
144
+ EOF
145
+ fi
146
+
124
147
# normally use non-debug version of nginx
125
148
NGINX_BIN=" /usr/sbin/nginx"
126
149
Original file line number Diff line number Diff line change @@ -201,9 +201,6 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
201
201
include /etc/nginx/caching.layer.listen;
202
202
server_name _;
203
203
204
- # allow to upload big layers
205
- client_max_body_size 0 ;
206
-
207
204
# Do some tweaked logging.
208
205
access_log /var/log/nginx/access.log tweaked;
209
206
set $docker_proxy_request_type "unknown" ;
@@ -222,6 +219,9 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
222
219
# Docker needs this. Don't ask.
223
220
chunked_transfer_encoding on ;
224
221
222
+ # configuration of the different allowed methods
223
+ include "/etc/nginx/conf.d/allowed.methods.conf"
224
+
225
225
proxy_read_timeout 900 ;
226
226
227
227
# Use cache locking, with a huge timeout, so that multiple Docker clients asking for the same blob at the same time
@@ -232,10 +232,6 @@ echo "Docker configured with HTTPS_PROXY=$scheme://$http_host/"
232
232
# Cache all 200, 206 for 60 days.
233
233
proxy_cache_valid 200 206 60d ;
234
234
235
- proxy_cache_convert_head off;
236
- proxy_cache_methods GET;
237
- proxy_cache_key $scheme$request_method$proxy_host$request_uri ;
238
-
239
235
# Some extra settings to maximize cache hits and efficiency
240
236
proxy_force_ranges on;
241
237
proxy_ignore_client_abort on ;
You can’t perform that action at this time.
0 commit comments