Securing Solr on Tomcat access using a user account

小咪咪 2022-09-20 12:55 178阅读 0赞
  • Open [Tomcat install dir]\tomcat-users.xml for editing.
  • Add the following lines within the element and save the changes (using your own username and password):

    1. <role rolename="solr_admin"/>
    2. <user username="your_username"
    3. password="your_password"
    4. roles="solr_admin"
    5. />

    Open [Tomcat install dir]\webapps\solr\WEB-INF\web.xml for editing.

    “solr“ in the path is the name of the instance you want to secure. Typically this is “solr,” but may be different if you are running an advanced setup.

  • Add the following lines within the element:

    1. <security-constraint>
    2. <web-resource-collection>
    3. <web-resource-name>Solr Lockdown</web-resource-name>
    4. <url-pattern>/</url-pattern>
    5. </web-resource-collection>
    6. <auth-constraint>
    7. <role-name>solr_admin</role-name>
    8. <role-name>admin</role-name>
    9. </auth-constraint>
    10. </security-constraint>
    11. <login-config>
    12. <auth-method>BASIC</auth-method>
    13. <realm-name>Solr</realm-name>
    14. </login-config>
  • Save the changes and restart Tomcat. Test your changes by starting a new browser session and navigating to your site, for ex. http://localhost:8080/solr/. You should be prompted for credentials.
  • Download the following communityserver_override.config file.
  • Place this file in the root of your Web site directory.
  • Find the section in this file which is highlighted below and change it to read
    http://**your\_username**:**your\_password**@localhost:8080/solr
    replacing “your_username” and “your_password” and the host URI with the configured values

    ?










    1


    2


    3


    4


    5



    <
    Override
    xpath
    =
    “/CommunityServer/Search/Solr”  


              
    mode
    =
    “change”


              
    name
    =
    “host”


              
    value
    =
    “<span style=”
    background-color:#ffff00;”>http://localhost:8080/solr</
    span
    >”


              
    />

  • Save changes.
  1. 本人的操作:
  2. 1.tomcatconf/tomcat-users.xml 添加
  3. <role rolename="solr_admin"/>
  4. <user username="your_username"
  5. password="your_password"
  6. roles="solr_admin"
  7. />
  8. 2.在![SouthEast][]
  9. 解压solr.war 找到web.xml
  10. 添加如下代码在<web-app></web-app> 元素中
  11. <security-constraint>
  12. <web-resource-collection>
  13. <web-resource-name>Solr select Lockdown</web-resource-name>
  14. <url-pattern>/cs/select/\*</url-pattern> //任何用户都可以访问
  15. </web-resource-collection>
  16. </security-constraint>
  17. <security-constraint>
  18. <web-resource-collection>
  19. <web-resource-name>Solr Lockdown</web-resource-name>
  20. <url-pattern>/</url-pattern>
  21. </web-resource-collection>
  22. <auth-constraint>
  23. <role-name>solr\_admin</role-name>
  24. </auth-constraint> //管理员访问
  25. </security-constraint>
  26. <login-config>
  27. <auth-method>BASIC</auth-method>
  28. <realm-name>Solr</realm-name>
  29. </login-config>

发表评论

表情:
评论列表 (有 0 条评论,178人围观)

还没有评论,来说两句吧...

相关阅读