你提到的 “debianjsp安全如何设置”,通常是指 在 Debian 系统上部署 JSP(一般是 Tomcat)时的安全加固。下面我从 系统层 → 服务层 → 应用层 给你一个实用清单。
apt update
apt upgrade -y
编辑:
nano /etc/ssh/sshd_config
设置:
PermitRootLogin no
PasswordAuthentication no
使用密钥登录更安全。
systemctl restart ssh
apt install ufw
ufw allow 22
ufw allow 80
ufw allow 443
ufw enable
创建专用用户:
useradd -r -m -s /bin/bash tomcat
chown -R tomcat:tomcat /opt/tomcat
启动:
su - tomcat -c "/opt/tomcat/bin/startup.sh"
rm -rf /opt/tomcat/webapps/ROOT
rm -rf /opt/tomcat/webapps/docs
rm -rf /opt/tomcat/webapps/examples
conf/server.xml
<Connector port="8080" ...
address="127.0.0.1" />
只对内网或 Nginx 反向代理开放。
rm -rf /opt/tomcat/webapps/manager
rm -rf /opt/tomcat/webapps/host-manager
如果必须用:
<!-- 注释掉 -->
<!-- <Connector port="8009" protocol="AJP/1.3" /> -->
WEB-INF/web.xml
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/error.jsp</location>
</error-page>
避免泄露:
web.xml
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
location / {
proxy_pass http://127.0.0.1:8080;
}
启用 HTTPS:
certbot --nginx
/var/log❌ root 运行 Tomcat
❌ 公网开放 8080
❌ 保留 manager 后台
❌ JSP 报错直接显示
如果你愿意,可以告诉我:
我可以给你一份 针对性的安全配置示例。