NGINXをもうちょっと設定
- 2022年5月10日
2022/03 の作業
NGINX の 443用の設定を追加する。
・http ヘッダの追加
・エラーページの設定
http ヘッダの追加
uwsgi で外した設定等をしていく。
80 で来たら、443 へリダイレクトするのは、certbot が入れてくれてるので、HSTS等をいれていく。
$ sudo vi /etc/nginx/sites-available/worksite_nginx.conf
server { server_name w1.massolezume.ga; ・・・・ server_tokens off; etag off; add_header X-Frame-Options DENY; add_header X-XSS-Protection "1; mode=block"; add_header X-Content-Type-Options nosniff; # 1行で書かないといけないらしい add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://ssl.google-analytics.com https://cdnjs.cloudflare.com https://my-bucket.s3.amazonaws.com; img-src 'self' https://ssl.google-analytics.com https://my-bucket.s3.amazonaws.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://themes.googleusercontent.com https://my-bucket.s3.amazonaws.com; font-src https://my-bucket.s3.amazonaws.com; frame-src 'none'; object-src 'none';"; add_header Strict-Transport-Security 'max-age=3600; includeSubDomains; preload'; ・・・・
エラーページの設定
http エラーがなんでも同じページにしておく。
$ sudo vi /etc/nginx/sites-available/worksite_nginx.conf
server { server_name w1.massolezume.ga; ・・・・ location / { uwsgi_pass django; include /etc/nginx/uwsgi_params; # uwsgi の設定で作成したファイル error_page 502 @custom_error; } root /home/nginx/html; error_page 404 @custom_error; error_page 500 502 503 504 @custom_error; location @custom_error { root /home/nginx/html; rewrite ^(.*)$ /custom_error.html break; internal; } ・・・・