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

相关推荐
程序员小八77719 小时前
Go Web 工程化:日志、配置与错误处理中间件,让服务「能上线」
前端·中间件·golang
tqs_1234519 小时前
SaaS 多租户 Agent 平台实战:自研 Agent 中间件 SDK,Nacos 配置驱动实现开箱即用
中间件
未若君雅裁1 天前
自定义中间件:Node-style 与 Wrap-style 钩子全解析
python·中间件·langchain
__zRainy__3 天前
Node系列 · Express:常用的中间件
中间件·node.js·express
2601_962181963 天前
【ROS2 中间件RMW】基于FastDDS共享内存实现ROS2跨进程零拷贝通讯
中间件
未若君雅裁3 天前
上下文压缩双刃剑-Summarization与ContextEditing中间件实战
python·中间件·langchain
烂蜻蜓3 天前
Flask入门教程(十六):中间件与扩展——增强应用功能的两种机制
python·中间件·flask
Best-Wishes3 天前
好靶场杯第一届-古法 流量包分析
计算机网络·web安全·安全威胁分析
__zRainy__4 天前
Node系列 · Express:中间件
中间件·node.js·express
LayZhangStrive5 天前
后端开发中间件 - Nacos下载并快速使用教程
中间件·nacos