tomcat-nginx 加固

nginx 加固php

禁止显示版本html

server_tokens off;
或者经过源码编译的时候修改
/src/core/nginx.h
#define NGINX_VERSION "1.9.15"
#define NGINX_VER "nginx/" NGINX_VERSIONnginx

禁止上传目录禁止php文件git

单个目录
location ~ /upload/.*.(php|php5)?$ {
deny all;
}web

多个目录
location ~ ^/(administrator|upload)/..(php)$ {
deny all;
}sql

禁止访问全部目录下的敏感文件apache

location ~. *.(sql|log|txt|rar|zip|sh|py|svn|git) {
deny all;
}tomcat

禁用没必要要的HTTP方法安全

if ($request_method !~ ^(GET|HEAD|POST)$)
{
return 405;
}cookie

Nginx、php-fpm运行账号及组为nobody

Lua + nginx

tomcat加固
tomcat弱口令拿Shell

tomcat tomcat
admin 空
admin admin
admin 123456

补丁和漏洞管理

必须及时安装与安全性相关的tomcat补丁
http://tomcat.apache.org/lists.html#tomcat-announce

设置Tomcat服务最小权限

useradd -s /sbin/nologin tomcat

/usr/lib/systemd/system/tomcat8.service
service下添加 User=tomcat Group=tomcat

chown -R tomcat:tomcat /usr/local/tomcat

网络级限制

tomcat8上已经禁止全部,只容许本地访问。

/usr/local/tomcat/webapps/manager/META-INF/context.xml

<Valve className="org.apache.catalina.valves.RemoteHostValve"
allow=".*.admins.domain.com"
/>

用户管理

tomcat-users.xml

<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="admin" password="123ccc" roles="manager-gui,manager-script,manager-jmx,manager-status"/>

隐藏tomcat版本信息

修改$CATALINA_HOME/conf/server.xml,在Connector节点添加server字段

/usr/local/tomcat/lib/org/apache/catalina/util

关闭自动部署

在$CATALINA_HOME/conf/server.xml中的host字段

<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">

session超时
/conf/web.xml
<session-config>
<session-timeout>20</session-timeout>
</session-config>

启用cookie的HttpOnly属性CATALINA_BASE/conf/context.xml<Context useHttpOnly='true' .../>

相关文章
相关标签/搜索