Nginx
這個 Nginx 配置有多安全?我還能做些什麼來進一步優化它?
所以我最近設置了一個個人 GitLab 伺服器,我正在使用以下配置和完整的 SSL。我盡了最大的努力,但還能做些什麼來讓它變得更好?我主要是通過在業餘時間玩弄它來了解我對網路伺服器的了解,所以我並沒有真正遵循任何約定。請讓我知道任何意見和疑慮。
server_tokens off; add_header X-Frame-Options SAMEORIGIN; add_header X-Content-Type-Options nosniff; add_header X-XSS-Protection "1; mode=block"; add_header Content-Security-Policy "default-src 'self'; script-src 'self''unsafe-inline' 'unsafe-eval' https://ssl.google-analytics.com h https://assets.zendesk.com https://connect.facebook.net; img-src 'self' https://ssl.google-analytics.com https://s-static.ak.facebook.com https://assets.zendesk.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://assets.zendesk.com; font-src 'self' https://themes.googleusercontent.com; frame-src https://assets.zendesk.com https://www.facebook.com https://s-static.ak.facebook.com https://tautt.zendesk.com; object-src 'none'"; server { listen 80; listen 443 default ssl spdy; server_name gitlab.example.com; add_header Strict-Transport-Security "max-age=31536000; includeSubdomains"; ssl_certificate /etc/nginx/ssl/gitlab.crt; ssl_certificate_key /etc/nginx/ssl/gitlab.key; ssl_dhparam /etc/nginx/ssl/dhparams.pem; ssl_session_cache shared:SSL:50m; ssl_session_timeout 5m; ssl_prefer_server_ciphers on; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_stapling on; ssl_stapling_verify on; ssl_trusted_certificate /etc/nginx/ssl/CA/comodo.pem; resolver 8.8.8.8; ssl_ciphers "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK"; location / { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Ssl on; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Frame-Options SAMEORIGIN; proxy_pass http://192.168.1.139:82; proxy_redirect http://192.168.1.139:82 https://gitlab.example.com; } }
您
add_header Strict-Transport-Security ...
的 in塊從上層server
刪除s 。add_header
proxy_redirect
是多餘的。您只是使用了預設值,而且如果您碰巧更改proxy_pass
並忘記更改,proxy_redirect
您會得到奇怪的錯誤。
proxy_set_header X-Frame-Options
是沒有意義的。
proxy_set_header X-Forwarded-Ssl on
很奇怪,因為您允許非 SSL 連接。