如何配置jetty以允许从外部服务器访问? [英] How do you configure jetty to allow access from an external server?

查看:1849
本文介绍了如何配置jetty以允许从外部服务器访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过这个问题,没有好的答案,你如何配置jetty允许从外部服务器访问?我刚开始搞砸了solr和jetty,并且使用solr附带的示例jetty实例。



solr在localhost上正常运行,我可以查询它来自同一服务器上的网站。但是,我无法从另一个服务器访问solr实例。在过去几天里,我已经搜索了一些内容,但是没有找到可以允许非本地主机访问solr的内容。



基于我已经尝试添加以下行到示例/ etc / jetty.xml

 < Set name = Host> 0.0.0.0< / Set> 

,但仍未收到外部回应



然后尝试

 < Set name =Host> xxxx< / Set& 

其中xxxx是我服务器的IP地址

 < Set name =Host> host.domain.com< / Set> 

其中host.domain.com是我的服务器的FQDN



这两个都导致错误

  java.net.BindException:无法分配请求的地址





我使用的开始命令是

  sudo java -jar start.jar etc / jetty.xml 

你可以指点我可以在这里读书,或者勺子喂我,我不在乎。我只想过这个障碍,所以我可以继续学习设置和使用solr。

解决方案

一个名为clientaccesspolicy.xml的文件,用于跨域访问您的静态网络文件目录:

 < access-policy> 
< cross-domain-access>
< policy>
< allow-from http-methods =*http-request-headers =*>
< domain uri =http:// */>
< domain uri =https:// */>
< / allow-from>
< grant-to>
< resource path =/include-subpaths =true/>
< / grant-to>
< / policy>
< / cross-domain-access>
< / access-policy>

您应该使用此代码将静态目录设置为jetty:

  ResourceHandler staticHandler = new ResourceHandler(); 
staticHandler.setResourcesBase(static / dir);
handlers.addHandler(staticHandler);


I've seen this asked before, with no good answers, how do you configure jetty to allow access from an external server? I've just started messing around with solr and jetty and am using the example jetty instance that comes with solr.

solr is running fine on localhost, and I can query it from sites on the same server. However, I can't access the solr instance from another server. I've googled and read quite a bit in the last few days, but have not been able to discover what's keeping jetty from allowing non localhost access to solr.

Based on what I've read, I have tried added the following line to example/etc/jetty.xml

<Set name="Host">0.0.0.0</Set> 

and still got no external response

then tried

<Set name="Host">x.x.x.x</Set>

where x.x.x.x is my server's IP address and

<Set name="Host">host.domain.com</Set>

where host.domain.com is my server's FQDN

These both resulted in the error

java.net.BindException: Cannot assign requested address

when I started.

The start command I'm using is

sudo java -jar start.jar etc/jetty.xml

You can point me to where I can read on this or spoon feed me, I don't care. I'd just like to get past this hurdle so I can keep learning about setting up and using solr.

解决方案

you should add a file called clientaccesspolicy.xml for cross domain access to your static web files directory:

<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from http-methods="*" http-request-headers="*">
        <domain uri="http://*"/>
        <domain uri="https://*"/>
      </allow-from>
      <grant-to>
        <resource path="/" include-subpaths="true"/>
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>

you should set you static directory to jetty using this code:

ResourceHandler staticHandler = new ResourceHandler();
staticHandler.setResourceBase("static/dir");
handlers.addHandler(staticHandler);

这篇关于如何配置jetty以允许从外部服务器访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆