Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DON'T MERGE YET] Add nginx config for X-Accel #144

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion autograder-server
Submodule autograder-server updated 28 files
+1 −3 autograder/core/fields.py
+66 −10 autograder/core/models/mutation_test_suite/mutation_test_suite_result.py
+11 −6 autograder/core/models/submission.py
+35 −6 autograder/core/submission_feedback.py
+30 −3 autograder/core/tests/test_submission_feedback/test_ag_test_suite_result_feedback.py
+17 −0 autograder/handgrading/tests/test_views/test_handgrading_result_views.py
+12 −11 autograder/handgrading/views/handgrading_result_views.py
+1 −1 autograder/non_html_debug_toolbar_middleware.py
+29 −0 autograder/rest_api/serve_file.py
+9 −0 autograder/rest_api/tests/test_views/test_course_views/test_course_views.py
+16 −6 autograder/rest_api/tests/test_views/test_project_views/test_instructor_file_views.py
+48 −0 autograder/rest_api/tests/test_views/test_project_views/test_project_views.py
+26 −1 autograder/rest_api/tests/test_views/test_sandbox_docker_image_views.py
+80 −19 ...test_views/test_submission_views/test_submission_result_views/test_ag_test_suite_and_command_output_fdbk.py
+58 −1 ...pi/tests/test_views/test_submission_views/test_submission_result_views/test_mutation_test_suite_feedback.py
+10 −10 autograder/rest_api/views/course_views/course_views.py
+12 −10 autograder/rest_api/views/project_views/instructor_file_views.py
+3 −2 autograder/rest_api/views/project_views/project_views.py
+8 −6 autograder/rest_api/views/sandbox_docker_image_views.py
+74 −67 autograder/rest_api/views/submission_views/submission_result_views.py
+2 −2 autograder/rest_api/views/submission_views/submission_views.py
+0 −2 autograder/settings/base.py
+7 −1 autograder/settings/development.py
+9 −0 autograder/settings/production.py
+5 −1 requirements-dev.txt
+2 −3 requirements.in
+5 −5 requirements.txt
+0 −12 uwsgi/uwsgi.ini
18 changes: 14 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
version: '3'

services:
nginx:
image: nginx:latest
restart: unless-stopped
ports:
- "9000:80"
volumes:
- ./nginx/conf.d:/etc/nginx/conf.d
- ./autograder-server/media_root_dev:/protected

django:
restart: unless-stopped
build:
context: ./autograder-server
dockerfile: Dockerfile-django-dev
container_name: typescript-cli-django
ports:
- "9000:9000"
volumes:
- ./autograder-server:/usr/src/app
command: >-
python3 manage.py runserver 0.0.0.0:9000
command: gunicorn --workers=1 autograder.wsgi:application --bind 0.0.0.0:8000 --error-logfile=- --access-logfile=-

env_file:
- ./autograder-server/_dev.env
environment:
# This gives us an extra way of verifying that we have X-Accel set up
# correctly
USE_NGINX_X_ACCEL: 'true'

# Set to false to disable real authentication. Any other string value
# will enable real authentication.
# Then, using a browser plugin such as EditThisCookie, set the
Expand Down
30 changes: 30 additions & 0 deletions nginx/conf.d/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# !!!!! DO NOT USE THIS CONFIG FILE IN PRODUCTION !!!!!


# Redirect http requests to https
server {
# Disable caching (otherwise we get some strange behavior because of
# the Docker volumes)
sendfile off;

# This should be the absolute path to media_root_dev. Used for
# X-Accel redirects.
location /protected {
internal;
root /;
}

location /api {
add_header Cache-Control "no-cache, no-store";
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;

proxy_pass http://django:8000;

client_max_body_size 30M;
# Disable buffering so large file downloads don't get cut off
proxy_max_temp_file_size 0;
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "2.4.4",
"description": "A client for interacting with the autograder.io API.",
"scripts": {
"test": "tsc -p . --noEmit && jest --runInBand",
"test": "tsc -p . --noEmit && jest --runInBand -b",
"lint": "tsc -p . --noEmit && tslint --project .",
"build": "tsc -p ."
},
Expand Down
4 changes: 2 additions & 2 deletions tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function reset_db() {
// Because of the overhead in flushing the database using manage.py flush,
// we'll instead delete all objects in the "top-level" tables that all
// the other data depends on.
let delete_data = `import shutil
let delete_data = `import subprocess
from django.core.cache import cache;
from django.contrib.auth.models import User
from autograder.core.models import Course, SandboxDockerImage, BuildSandboxDockerImageTask
Expand All @@ -30,7 +30,7 @@ User.objects.all().delete()
SandboxDockerImage.objects.exclude(name='default').delete()
BuildSandboxDockerImageTask.objects.all().delete()

shutil.rmtree('/usr/src/app/media_root_dev/', ignore_errors=True)
subprocess.run('rm -r /usr/src/app/media_root_dev/*', shell=True)
cache.clear()
`;
run_in_django_shell(delete_data);
Expand Down