Back to posts
How to enable solr SSL

How to enable solr SSL

Sohail Bhatti / November 29, 2024

How to Enable Solr SSL

Securing your Solr server with SSL is essential for protecting data in transit. Follow these steps to enable SSL in Apache Solr:

Step 1: Generate or Obtain an SSL Certificate

  1. Generate a self-signed certificate or obtain one from a Certificate Authority (CA).
  2. Use keytool to create a keystore:
    keytool -genkeypair -alias solr-ssl -keyalg RSA -keysize 2048 -keystore solr.keystore.jks -validity 365
  3. If using a CA-signed certificate, import it into the keystore:
    keytool -importcert -trustcacerts -alias solr-ssl -file your-certificate-file.crt -keystore solr.keystore.jks

Step 2: Configure Solr for SSL

  1. Locate your solr.in.sh (Linux) or solr.in.cmd (Windows) file.
  2. Add the following configurations to enable SSL:
     SOLR_SSL_ENABLED=true
     SOLR_SSL_KEY_STORE=path/to/solr.keystore.jks
     SOLR_SSL_KEY_STORE_PASSWORD=your-keystore-password
     SOLR_SSL_TRUST_STORE=path/to/solr.keystore.jks
     SOLR_SSL_TRUST_STORE_PASSWORD=your-truststore-password
  3. Restart the Solr service:
    bin/solr restart

Step 3: Test the SSL Configuration

  1. Access Solr using https in a browser:
    https://your-solr-host:8983/solr
    
  2. For curl, use:
    curl -k https://your-solr-host:8983/solr
    
  3. Update client libraries (e.g., SolrJ) to connect securely by adding truststore configurations.

Step 4: (Optional) Enforce HTTPS

Configure a reverse proxy like Apache or Nginx to redirect all HTTP traffic to HTTPS.

Conclusion

With SSL enabled, your Solr server is now secure, ensuring encrypted communication and protecting sensitive data.

Note: Replace paths and passwords with your actual file locations and secure credentials.

Let me know if you'd like further customization!