gpt4 book ai didi

security - Nginx 安全配置

转载 作者:太空宇宙 更新时间:2023-11-03 13:20:43 25 4
gpt4 key购买 nike

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

当前的设置涉及为当前在公共(public)云基础架构上运行的内部网络应用程序提供服务。

下面是我的nginx配置:

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 和相应的 key :mycustomapp.key,并且本地服务/应用程序正在运行在 http://localhost:9090 上并且在全局访问端口 0.0.0.0:9090 上运行。

这是 access.log 的片段,位于 /var/log/nginx/

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 中观察到一些格式错误的请求(此处未复制)。

配置是否足以延迟/阻止这些渗透攻击尝试,或者是否有冗余配置暴露了我目前无法理解的 channel ?

目前,我会在有人需要访问权限时启用该服务,但随着越来越多的人开始使用该应用程序,这将不再是一个合适的场景。

最佳答案

这个配置照常就够了。如需更多安全性,请查看此列表:

  1. > https://github.com/nbs-system/naxsi
  2. 使用this优化 SSL 性能。
  3. 了解 server_tokens 并禁用它。
  4. 阅读有关 error_page 的信息并使用您自己的页面。

关于security - Nginx 安全配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53910642/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com