diff --git a/docker/nginx/addons.conf.template b/docker/nginx/addons.conf.template index 66cf16735f18..17be2850b0a1 100644 --- a/docker/nginx/addons.conf.template +++ b/docker/nginx/addons.conf.template @@ -1,4 +1,4 @@ -client_max_body_size 50m; +client_max_body_size 200m; etag off; merge_slashes off; @@ -49,7 +49,7 @@ server { try_files $uri @olympia; } - location ~ ^/(__version__|__heartbeat__|services/monitor.json)(\?.*)?$ { + location ~ ^/(__version__|__heartbeat__|services).*$ { try_files $uri @olympia; } diff --git a/src/olympia/amo/urls.py b/src/olympia/amo/urls.py index 1d03dd194afc..be4475ac66e0 100644 --- a/src/olympia/amo/urls.py +++ b/src/olympia/amo/urls.py @@ -13,6 +13,7 @@ # which is useful to reach those services from an API request, to make them # work with services.a.m.o. or test their behavior with request.is_api # being True. + re_path(r'^dummy_upload', views.dummy_upload, name='amo.dummy_upload'), re_path(r'^client_info', views.client_info, name='amo.client_info'), re_path(r'^403', views.handler403), re_path(r'^404', views.handler404), diff --git a/src/olympia/amo/views.py b/src/olympia/amo/views.py index 864a29e1a9e4..29d9e6b9780c 100644 --- a/src/olympia/amo/views.py +++ b/src/olympia/amo/views.py @@ -1,6 +1,7 @@ import json import os import re +import time from django.conf import settings from django.contrib.auth.models import AnonymousUser @@ -73,6 +74,27 @@ def services_monitor(request): ) +@csrf_exempt +@non_atomic_requests +def dummy_upload(request): + if getattr(settings, 'ENV', None) == 'prod': + raise PermissionDenied + # dd if=/dev/urandom of=/tmp/test.img bs=100M count=1 + # curl -F parse=1 -F upload=@/tmp/test.img /services/dummy_upload + if request.POST.get('parse') and 'upload' in request.FILES: + buf = request.FILES['upload'].read() + else: + buf = '' + + return JsonResponse( + { + # request._start_time is set by GraphiteRequestTimingMiddleware + 'elapsed_in_app': int((time.time() - request._start_time) * 1000), + 'buf_size': len(buf), + } + ) + + @never_cache @csrf_exempt @non_atomic_requests