Skip to content

Instantly share code, notes, and snippets.

@ryu22e
Last active July 3, 2019 06:42
Show Gist options
  • Save ryu22e/310fa27f41c4ccda81b0b3eba204d69b to your computer and use it in GitHub Desktop.
Save ryu22e/310fa27f41c4ccda81b0b3eba204d69b to your computer and use it in GitHub Desktop.
Djangoの脆弱性CVE-2019–12781について解説(2)
# 以下gunicornのexampleをベースに作成
# https://github.com/benoitc/gunicorn/blob/master/examples/nginx.conf
# /etc/nginx/sites-available/default を上書きする想定
# 今回の脆弱性の確認に必要な最低限の設定だけ書いているので、本番でこの設定を丸ごとコピーして使わないように!
upstream app_server {
server 127.0.0.1:8000 fail_timeout=0;
}
server {
listen 80;
client_max_body_size 4G;
server_name 127.0.0.1;
keepalive_timeout 5;
# 静的ファイルの配信は行わないのでこのディレクトリは実際に作成しなくてよい。
root /path/to/app/current/public;
location / {
try_files $uri @proxy_to_app;
}
location @proxy_to_app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
}
server {
listen 443;
client_max_body_size 4G;
server_name 127.0.0.1;
keepalive_timeout 5;
# 静的ファイルの配信は行わないのでこのディレクトリは実際に作成しなくてよい。
root /path/to/app/current/public;
location / {
try_files $uri @proxy_to_app;
}
location @proxy_to_app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
ssl on;
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment