这个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连接.

相关文章

一、Linux下Nginx的安装 1.去官网 http://nginx.org/download/下载对应的Nginx安装包,推荐使...
一、空格:默认匹配、普通匹配 location / { root /home; } 二、= :精确匹配(表示匹配到 /home/resou...
``` nginx -c 配置文件路径 ``` ``` /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.con...
前言 nginx可所谓是如今最好用的软件级别的负载均衡了。通过nginx的高性能,并发能力强,占用内存下的特...
1.ngnix概念 Nginx是一款高性能的http 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器。由俄...
博客园从今天上午就开始报502错误 , 他的原因还不知道 , 暂时先说下我们遇到502的排查情况 最大的可能性...