这个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 …从上一级删除add_headers.

proxy_redirect是多余的.您刚刚使用了默认值,而且如果您碰巧更改了proxy_pass并忘记更改proxy_redirect,您将会遇到奇怪的错误.

proxy_set_header X-Frame-Options毫无意义.

proxy_set_header X-Forwarded-Ssl on很奇怪,因为你允许非ssl连接.

猜你在找的Nginx相关文章