赞
踩
nginx禁止显示版本有两种方法
vim /usr/local/nginx/conf/nginx.conf
server_tokens off;
/src/core/nginx.h
#define NGINX_VERSION "1.9.15"
#define NGINX_VER "nginx/" NGINX_VERSION
location ~ /upload/.*\.(php|php5)?$ {
deny all;
}
location ~* ^/(administrator|upload)/.*\.(php)$ {
deny all;
}
location ~. *\.(sql|log|txt|rar|zip|sh|py|svn|git) {
deny all;
}
if ($request_method !~ ^(GET|HEAD|POST)$)
{
return 405;
}
必须及时安装与安全性相关的tomcat补丁
http://tomcat.apache.org/lists.html#tomcat-announce
useradd -s /sbin/nologin tomcat
/usr/lib/systemd/system/tomcat8.service
[Service]
下添加
User=tomcat
Group=tomcat
chown -R tomcat:tomcat /usr/local/tomcat
tomcat8上已经禁止所有,只允许本地访问。8以下的版本可以使用下面代码来实现
/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"/>
修改$CATALINA_HOME/conf/server.xml
,在Connector节点添加server
字段
或者修改下面路径的jar中的配置文件
/usr/local/tomcat/lib/org/apache/catalina/util
在$CATALINA_HOME/conf/server.xml
中的host字段unpackWARs
改为false
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
/conf/web.xml
<session-config>
<session-timeout>20</session-timeout>
</session-config>
CATALINA_BASE/conf/context.xml
<Context useHttpOnly='true' .../>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。