Skip to content

Commit

Permalink
fix: nginx 설정 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
wndjs803 committed Jan 30, 2024
1 parent 32fba51 commit 22f6ff6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
python manage.py makemigrations subscribe && \
python manage.py makemigrations summary && \
python manage.py migrate && python manage.py loaddata test.json && \
daphne -b 0.0.0.0 -p 8000 nTeamProject.asgi:application"
python manage.py runserver 0.0.0.0:8000"
ports:
- 8000:8000
volumes:
Expand Down
20 changes: 18 additions & 2 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ http {
}

location / {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, DELETE, OPTIONS';
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, DELETE, PATCH, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization';
add_header 'Access-Control-Max-Age' 86400;
return 204;
}
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Content-Type' 'application/json' always;

return 301 https://$host$request_uri;
}
Expand All @@ -46,6 +53,15 @@ http {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, DELETE, PATCH, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization';
add_header 'Access-Control-Max-Age' 86400;
return 204;
}
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Content-Type' 'application/json' always;
}

location /ws {
Expand Down

0 comments on commit 22f6ff6

Please sign in to comment.