You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by LongY <zh...@hotmail.com> on 2015/03/16 20:39:36 UTC

Nginx proxy for Solritas

Dear Community Members,

I have searched over the forum and googled a lot, still didn't find the
solution. Finally got me here for help.
 
I am implementing a Nginx reverse proxy for Solritas
(VelocityResponseWriter) of the example included in Solr.
. Nginx listens on port 80, and solr runs on port 8983. This is my Nginx
configuration file (It only permits localhost
to access the browse request handler).

*location ~* /solr/\w+/browse {
               proxy_pass          http://localhost:8983;

                allow   127.0.0.1;
                deny    all;

                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;
              
        }*

when I input http://localhost/solr/collection1/browse in the browser address
bar. 
 The output I got is this. 
<http://lucene.472066.n3.nabble.com/file/n4193346/left.png> 
The supposed output should be like this 
<http://lucene.472066.n3.nabble.com/file/n4193346/right.png> 

I tested the Admin page with this Nginx configuration file with some minor
modifications, it worked well,
but when used in velocity templates, it did not render the output properly.
 
Any input is welcome.
Thank you.



--
View this message in context: http://lucene.472066.n3.nabble.com/Nginx-proxy-for-Solritas-tp4193346.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Nginx proxy for Solritas

Posted by Shawn Heisey <ap...@elyograg.org>.
On 3/16/2015 2:42 PM, LongY wrote:
> Thank you for the reply.
>
> I also thought the relevant resources (CSS, images, JavaScript) need to 
> be accessible for Nginx. 
>
> I copied the velocity folder to solr-webapp/webapp folder. It didn't work.
>
> So how to allow /browse resource accessible by the Nginx rule?

The /browse handler causes your browser to make requests directly to
Solr on handlers other than /browse.  You must figure out what those
requests are and allow them in the proxy configuration.  I do not know
whether they are relative URLs ... I would not be terribly surprised to
learn that they have port 8983 in them rather than the port 80 on your
proxy.  Hopefully that's not the case, or you'll really have problems
making it work on port 80.

I've never spent any real time with the /browse handler.  Requiring
direct access to Solr is completely unacceptable for us.

Thanks,
Shawn


Re: Nginx proxy for Solritas

Posted by LongY <zh...@hotmail.com>.
Thanks to Erik and Shawn, I figured out the solution.

* place main.css in velocity folder into
/usr/share/nginx/html/solr/collection1/admin/file/
* don't forget to change the permission of main.css by sudo chmod 755
main.css
* add main.css to the configuration file of Ngix:
server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;
        index main.css;
        server_name localhost;
        location ~* /solr/\w+/browse {
        proxy_pass   http://localhost:8983; 
                allow   127.0.0.1;
                deny    all;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;
             
        } 
}
That will work.
Also /var/log/nginx/error.log is good for debugging.




--
View this message in context: http://lucene.472066.n3.nabble.com/Nginx-proxy-for-Solritas-tp4193347p4193415.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Nginx proxy for Solritas

Posted by Erik Hatcher <er...@gmail.com>.
Have a look at the requests being made to Solr while using /browse (without nginx) and that will show you what resources need to be accessible.


—
Erik Hatcher, Senior Solutions Architect
http://www.lucidworks.com <http://www.lucidworks.com/>




> On Mar 16, 2015, at 4:42 PM, LongY <zh...@hotmail.com> wrote:
> 
> Thank you for the reply.
> 
> I also thought the relevant resources (CSS, images, JavaScript) need to 
> be accessible for Nginx. 
> 
> I copied the velocity folder to solr-webapp/webapp folder. It didn't work.
> 
> So how to allow /browse resource accessible by the Nginx rule?
> 
> 
> 
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Nginx-proxy-for-Solritas-tp4193347p4193352.html
> Sent from the Solr - User mailing list archive at Nabble.com.


Re: Nginx proxy for Solritas

Posted by LongY <zh...@hotmail.com>.
Thank you for the reply.

I also thought the relevant resources (CSS, images, JavaScript) need to 
be accessible for Nginx. 

I copied the velocity folder to solr-webapp/webapp folder. It didn't work.

So how to allow /browse resource accessible by the Nginx rule?



--
View this message in context: http://lucene.472066.n3.nabble.com/Nginx-proxy-for-Solritas-tp4193347p4193352.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Nginx proxy for Solritas

Posted by Erik Hatcher <er...@gmail.com>.
The links to the screenshots aren’t working for me.  I’m not sure what the issue is - but do be aware that /browse with its out of the box templates do refer to resources (CSS, images, JavaScript) that isn’t under /browse, so you’ll need to allow those to be accessible as well with different rules.


—
Erik Hatcher, Senior Solutions Architect
http://www.lucidworks.com <http://www.lucidworks.com/>




> On Mar 16, 2015, at 3:39 PM, LongY <zh...@hotmail.com> wrote:
> 
> Dear Community Members,
> 
> I have searched over the forum and googled a lot, still didn't find the
> solution. Finally got me here for help.
> 
> I am implementing a Nginx reverse proxy for Solritas
> (VelocityResponseWriter) of the example included in Solr.
> . Nginx listens on port 80, and solr runs on port 8983. This is my Nginx
> configuration file (It only permits localhost
> to access the browse request handler).
> 
> *location ~* /solr/\w+/browse {
>               proxy_pass          http://localhost:8983;
> 
>                allow   127.0.0.1;
>                deny    all;
> 
>                proxy_set_header X-Real-IP $remote_addr;
>                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>                proxy_set_header Host $http_host;
> 
>        }*
> 
> when I input http://localhost/solr/collection1/browse in the browser address
> bar. 
> The output I got is this. 
> <http://lucene.472066.n3.nabble.com/file/n4193346/left.png> 
> The supposed output should be like this 
> <http://lucene.472066.n3.nabble.com/file/n4193346/right.png> 
> 
> I tested the Admin page with this Nginx configuration file with some minor
> modifications, it worked well,
> but when used in velocity templates, it did not render the output properly.
> 
> Any input is welcome.
> Thank you.
> 
> 
> 
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Nginx-proxy-for-Solritas-tp4193346.html
> Sent from the Solr - User mailing list archive at Nabble.com.