geoserver发布图层修复安全漏洞

一、关闭geoserver服务web、rest、gwc/rest管理页面

1、tomcat

tomcat发布的geoserver服务中,进入tomcat/webapps/geoserver/WEB-INF,打开web.xml文件,

在文件最后添加如下配置

java 复制代码
<security-constraint>
     <web-resource-collection>
         <web-resource-name>Block web and rest</web-resource-name>
         <url-pattern>/web/*</url-pattern>
         <url-pattern>/rest/*</url-pattern>
         <url-pattern>/gwc/*</url-pattern>
         <url-pattern>/web.html</url-pattern>
         <url-pattern>/web.htm</url-pattern>
         <url-pattern>/web.webj</url-pattern>
         <url-pattern>/web.web</url-pattern>
         <url-pattern>/web.jsp</url-pattern>
         <url-pattern>/web.jspx</url-pattern>
         <url-pattern>/rest.html</url-pattern>
         <url-pattern>/rest.htm</url-pattern>
         <url-pattern>/rest.webj</url-pattern>
         <url-pattern>/rest.web</url-pattern>
         <url-pattern>/rest.jsp</url-pattern>
         <url-pattern>/rest.jspx</url-pattern>
     </web-resource-collection>
     <auth-constraint>
         <!-- 空auth-constraint表示不允许任何角色访问 -->
     </auth-constraint>
 </security-constraint>

配置完成后重启tomcat

2、东方通

通过东方通发布的geoserver服务,与tomcat类似,配置完成后重启东方通

3、nginx

通过nginx代理geoserver服务,在nginx的配置文件nginx.conf中添加相关配置

java 复制代码
http中添加白名单配置
geo  $admin_whitelist {
    default 0;
    127.0.0.1 1;
    192.168.1.0/24 1;
    58.247.17.139 1;
}
java 复制代码
# GeoServer 配置
location /geoserver/ {
	 #       proxy_pass http://127.0.0.1:2443;
	 #       proxy_set_header Host $host;
	 #       proxy_set_header X-Real-IP $remote_addr;


		 location ~* ^/geoserver/(web|rest) {
		
		        # 重要:确保 proxy_pass 正确工作
		        proxy_pass http://127.0.0.1:2443;
		        
		
		        proxy_set_header Host $host;
		        proxy_set_header X-Real-IP $remote_addr;
		        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		        proxy_set_header X-Forwarded-Proto $scheme;
		
		           if ($admin_whitelist != 1) {
		                access_log logs/geoserver_admin_denied.log;
		                return 403;
		            }
		            allow all;
		            access_log logs/geoserver_admin_access.log;
		
		}

		location ~* ^/geoserver/([^/]+)/(wms|wfs|wcs|wmts|ows) {
		        # 重要:确保 proxy_pass 正确工作
		        proxy_pass http://127.0.0.1:2443;
		         
		        proxy_set_header Host $host;
		        proxy_set_header X-Real-IP $remote_addr;
		        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		        proxy_set_header X-Forwarded-Proto $scheme;
		
	            allow all;
	            proxy_read_timeout 120s;
		
		}

   deny all;
   return 404;
}

4、geoserver添加authkey认证访问

第一步:在官网下载对应版本的authkey插件

第二步:将下载的插件jar包,放到geoserver的lib目录中geoserver\WEB-INF\lib

第三步:启动geoserver,进入后台管理页面,一定需要修改密码

第四步:配置权限认证。添加UUID b52d2068-0a9b-45d7-kedu-144d12222025

第五步:设置过滤器


第六步:添加过滤器


第七步:保存配置

第八步:访问测试,访问所有的工作空间都需要加&authkey=b52d2068-0a9b-45d7-kedu-144d12222025

相关推荐
X7x51 天前
堡垒机:企业运维安全的“数字守门人“
网络安全·网络攻击模型·安全威胁分析·堡垒机·安全架构
哥本哈士奇2 天前
LangChain Deepagent 版本0.6.1中间件一个bug
中间件·langchain·bug
路baby2 天前
RCE漏洞的原理详细讲解并基于pikachu靶场的实战演戏
安全·web安全·网络安全·系统安全·网络攻击模型·安全威胁分析·rce
X7x52 天前
网络流量分析(NTA):企业安全运营的“数字听诊器“
网络安全·网络攻击模型·安全威胁分析·安全架构·nta
逍遥德2 天前
SpringBoot自带TaskScheduler 接口使用详解:(02)微服务多实例模式下,爆发任务重复执行问题
spring boot·分布式·后端·微服务·中间件
Chockmans2 天前
春秋云境CVE-2022-28512(手工注入和sqlmap自动)保姆级教学
安全·web安全·网络安全·网络攻击模型·安全威胁分析·春秋云境·cve-2022-28512
灰乌鸦乌卡2 天前
关于OA自定义接口不能解析汉字记录
java·中间件
fuquxiaoguang2 天前
从“能跑起来”到“能跑稳”:Google Genkit如何用中间件思维改写AI工程化规则
人工智能·中间件·genkit
X7x53 天前
网络入侵防御系统(IPS):从被动防御到主动拦截的网络安全革命
网络安全·网络攻击模型·安全威胁分析·安全架构·ips
June bug3 天前
【AI赋能测试笔记】3中间件
人工智能·中间件