欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

solr限制admin界面访问(端口限制和http授权限制),solradmin,solr的管理界面可以帮

来源: javaer 分享于  点击 7871 次 点评:185

solr限制admin界面访问(端口限制和http授权限制),solradmin,solr的管理界面可以帮


solr的管理界面可以帮助我们做很多事情,但是把solr程序放到公网之后就要限制对admin的访问了。

可以通过tomcat的http基本授权来做限制,也可以通过iptables防火墙来限制。

我们先看如何通过tomcat配置http授权限制。

第一步: 在tomcat的conf/tomcat-users.xml文件中添加管理用户,比如:

<user username="admin" password="new-password" roles="admin, manager"/>

第二步: 修改solr web程序的web.xml文件,添加对/admin路径的授权限制:

<security-constraint> <web-resource-collection> <web-resource-name>  Restrict access to Solr admin</web-resource-name> <url-pattern>/admin/*</url-pattern> <http-method>DELETE</http-method> <http-method>GET</http-method> <http-method>POST</http-method> <http-method>PUT</http-method> </web-resource-collection> <auth-constraint > <role-name>manager</role-name>  </auth-constraint>  <user-data-constraint> <transport-guarantee>NONE</transport-guarantee> </user-data-constraint></security-constraint><login-config><auth-method>BASIC</auth-method><realm-name>default</realm-name></login-config>

这段xml要放在根节点web-app的节点内。

这样配置之后就可以重启tomcat,实现基本授权了。

第二种限制solr admin的方式是通过iptables,限制外网对solr tomcat端口的访问

sudo iptables -A INPUT -p tcp -s localhost --dport 8983 -j ACCEPTsudo iptables -A INPUT -p tcp --dport 8983 -j DROP

上面命令的第一行允许localhost对8983端口访问,限制其他ip对这个端口的访问。

相关栏目:

用户点评