Can't Access Solr from my Webserver on Amazon EC2 Instance
I was having problems with a few of my sites. I have them hosted on amazon ec2, so I thought I could set up the server in a highly customized fashion. I have a simple search function for one of my sites, but I wanted a more advanced search capability. Solr looks like a great solution. Many hosted servers do not let you run java applications but this is simple on an ec2 server. So I downloaded and installed solr on my server. It is a little complex to configure but that is solved with a little time and elbowgrease.
The Problem The biggest problem I had was after configuring and indexing my database, I needed to access solr from the php application. One guide I had suggested pinging the service to make sure it worked and was accessible. I discovered that I could not even ping my server!! I solved this in a separate article, here. After getting pings working, I set my webserver php app to access solr via localhost (actually, I used 127.0.0.1:8983),and it produced… nothing.
The Solution I worked on it for a while then put it on the shelf. A few days later, I was back on it, and one search mentioned something that made me think. I realized that even if local ip was not useable, there was the ip for the server itself! I do not want to open solr to the whole world, so I thought a bit more, then realized that the AWS console will allow you to set access according to ip of origin. I went to the security section, and added a rule: open port 8983, but open it only to one ip address: the ip address for the server itself! this worked like a charm. Safe, and smooth. I tested it with a curl request and sure enough, problem solved.