首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Nginx安全配置

Nginx安全配置
EN

Stack Overflow用户
提问于 2018-12-24 07:48:43
回答 1查看 567关注 0票数 1

我对Nginx作为内部web服务的代理的配置有点陌生,需要使用SSL连接进行转发。

目前的设置涉及到一个内部web应用程序,该应用程序目前运行在公共云基础设施上。

下面是我的nginx配置:

代码语言:javascript
复制
server {
  listen 80 default_server;
  listen [::]:80 default_server;
  server_name www.somedomain.com;
  # Refer:
  # https://www.nginx.com/blog/http-strict-transport-security-hsts-and-nginx/
  # Discourage deep links by using a permanent redirect to home page of HTTPS site
  return 301 https://$server_name;
}

server {
  # User Defined
  listen 443 ssl http2;
  # SSL Certificate Paths
  ssl_certificate /home/secured/ssl/certs/mycustomapp.cert;
  ssl_certificate_key /home/secured/ssl/private/mycustomapp.key;

  # Nginx Access and Error Logs
  access_log /var/log/nginx/mycustomapp.access.log;
  error_log  /var/log/nginx/mycustomapp.error.log;

  # Add index.php to the list if you are using PHP
  index index.html index.htm index.nginx-debian.html;

  # User Defined
  server_name www.somedomain.com;

  # HSTS header for always https option
  add_header Strict-Transport-Security "max-age=36000; includeSubDomains" always;
  add_header X-Frame-Options "DENY";

  location / {
    # User Defined
    include /etc/nginx/proxy_params;
    proxy_pass http://localhost:9090;
    proxy_read_timeout 90s;
    proxy_redirect http://localhost:9090 https://$server_name;
  }
}

其中,我为服务器生成了一个自签名证书:mycustomapp.cert和相应的键in:mycustomapp.key,本地服务/应用程序运行在http://localhost:9090上,而不是运行在全局访问端口0.0.0.0:9090上。

这里是access.log的片段,可以在这个位置使用/var/log/nginx/

代码语言:javascript
复制
106.51.17.223 - - [23/Dec/2018:17:51:22 +0000] "GET / HTTP/1.1" 301 194 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
47.75.165.214 - - [23/Dec/2018:18:16:47 +0000] "PROPFIND / HTTP/1.1" 301 194 "-" "-"
47.75.165.214 - - [23/Dec/2018:18:16:47 +0000] "GET /webdav/ HTTP/1.1" 301 194 "-" "Mozilla/5.0"
47.75.165.214 - - [23/Dec/2018:18:16:47 +0000] "GET /help.php HTTP/1.1" 301 194 "-" "Mozilla/5.0 (Windows NT 5.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 SE 2.X MetaSr 1.0"
47.75.165.214 - - [23/Dec/2018:18:16:48 +0000] "GET /java.php HTTP/1.1" 301 194 "-" "Mozilla/5.0 (Windows NT 5.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 SE 2.X MetaSr 1.0"
47.75.165.214 - - [23/Dec/2018:18:16:58 +0000] "POST /wuwu11.php HTTP/1.1" 301 194 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
47.75.165.214 - - [23/Dec/2018:18:16:58 +0000] "POST /xw.php HTTP/1.1" 301 194 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
47.75.165.214 - - [23/Dec/2018:18:16:59 +0000] "POST /xw1.php HTTP/1.1" 301 194 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
47.75.165.214 - - [23/Dec/2018:18:16:59 +0000] "POST /9678.php HTTP/1.1" 301 194 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"

我还在access.logmycustomapp.access.log中观察到一些格式错误的请求(这里没有复制)。

该配置是否足以延迟/阻止这些穿透攻击尝试,还是存在一个冗余配置,它暴露了一个目前我无法理解的通道?

目前,当有人需要访问时,我正在启用该服务,但在越来越多的人开始使用该应用程序时,这并不是一个合适的场景。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-12-24 17:53:21

像往常一样,这个配置就足够了。要获得更多安全信息,请查看以下列表:

  1. https://github.com/nbs-system/naxsi
  2. 使用来提高SSL性能。
  3. 阅读server_tokens并禁用它。
  4. 阅读error_page并使用您自己的页面。
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53910642

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档