在Windows上使用Jetty 9.4
对于http,每当有另一个IP地址时,我只需将jetty-http.xml复制到etc文件夹并编辑该文件以使另一个连接器与其他所有连接器相同,但IP地址除外,如下例所示(在本例中为我的IP)是1.2.3.4和1.2.3.5)
<Call name="addConnector">
<Arg>
<New id="httpConnector" class="org.eclipse.jetty.server.ServerConnector">
<Arg name="server"><Ref refid="Server" /></Arg>
<Arg name="acceptors" type="int"><Property name="jetty.http.acceptors" deprecated="http.acceptors" default="-1"/></Arg>
<Arg name="selectors" type="int"><Property name="jetty.http.selectors" deprecated="http.selectors" default="-1"/></Arg>
<Arg name="factories">
<Array type="org.eclipse.jetty.server.ConnectionFactory">
<Item>
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
<Arg name="config"><Ref refid="httpConfig" /></Arg>
<Arg name="compliance"><Call class="org.eclipse.jetty.http.HttpCompliance" name="valueOf"><Arg><Property name="jetty.http.compliance" default="RFC7230"/></Arg></Call></Arg>
</New>
</Item>
</Array>
</Arg>
<Set name="host">1.2.3.5</Set>
<Set name="port">80</Set>
<Set name="idleTimeout"><Property name="jetty.http.idleTimeout" deprecated="http.timeout" default="30000"/></Set>
<Set name="soLingerTime"><Property name="jetty.http.soLingerTime" deprecated="http.soLingerTime" default="-1"/></Set>
<Set name="acceptorPriorityDelta"><Property name="jetty.http.acceptorPriorityDelta" deprecated="http.acceptorPriorityDelta" default="0"/></Set>
<Set name="acceptQueueSize"><Property name="jetty.http.acceptQueueSize" deprecated="http.acceptQueueSize" default="0"/></Set>
</New>
</Arg>
<Call name="addConnector">
<Arg>
<New id="sslConnector" class="org.eclipse.jetty.server.ServerConnector">
<Arg name="server"><Ref refid="Server" /></Arg>
<Arg name="acceptors" type="int"><Property name="jetty.ssl.acceptors" deprecated="ssl.acceptors" default="-1"/></Arg>
<Arg name="selectors" type="int"><Property name="jetty.ssl.selectors" deprecated="ssl.selectors" default="-1"/></Arg>
<Arg name="factories">
<Array type="org.eclipse.jetty.server.ConnectionFactory">
<!-- uncomment to support proxy protocol
<Item>
<New class="org.eclipse.jetty.server.ProxyConnectionFactory"/>
</Item>-->
</Array>
</Arg>
<Set name="host">1.2.3.4</Set>
<Set name="port">443</Set>
<Set name="idleTimeout"><Property name="jetty.ssl.idleTimeout" deprecated="ssl.timeout" default="30000"/></Set>
<Set name="soLingerTime"><Property name="jetty.ssl.soLingerTime" deprecated="ssl.soLingerTime" default="-1"/></Set>
<Set name="acceptorPriorityDelta"><Property name="jetty.ssl.acceptorPriorityDelta" deprecated="ssl.acceptorPriorityDelta" default="0"/></Set>
<Set name="acceptQueueSize"><Property name="jetty.ssl.acceptQueueSize" deprecated="ssl.acceptQueueSize" default="0"/></Set>
</New>
</Arg>
但是,对于https。当我对文件ssl-jetty.xml执行相同操作时如下
<Call name="addConnector">
<Arg>
<New id="sslConnector" class="org.eclipse.jetty.server.ServerConnector">
<Arg name="server"><Ref refid="Server" /></Arg>
<Arg name="acceptors" type="int"><Property name="jetty.ssl.acceptors" deprecated="ssl.acceptors" default="-1"/></Arg>
<Arg name="selectors" type="int"><Property name="jetty.ssl.selectors" deprecated="ssl.selectors" default="-1"/></Arg>
<Arg name="factories">
<Array type="org.eclipse.jetty.server.ConnectionFactory">
<!-- uncomment to support proxy protocol
<Item>
<New class="org.eclipse.jetty.server.ProxyConnectionFactory"/>
</Item>-->
</Array>
</Arg>
<Set name="host">1.2.3.5</Set>
<Set name="port">443</Set>
<Set name="idleTimeout"><Property name="jetty.ssl.idleTimeout" deprecated="ssl.timeout" default="30000"/></Set>
<Set name="soLingerTime"><Property name="jetty.ssl.soLingerTime" deprecated="ssl.soLingerTime" default="-1"/></Set>
<Set name="acceptorPriorityDelta"><Property name="jetty.ssl.acceptorPriorityDelta" deprecated="ssl.acceptorPriorityDelta" default="0"/></Set>
<Set name="acceptQueueSize"><Property name="jetty.ssl.acceptQueueSize" deprecated="ssl.acceptQueueSize" default="0"/></Set>
</New>
</Arg>
Exception in thread "main" java.lang.IllegalStateException: No protocol factory for default protocol: null
at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:258)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:81)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:235)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:390)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1516)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1441)
如下所示获取此异常。不知道这里遗漏了什么?
{{1}}
答案 0 :(得分:0)
我绝不是码头专家;但是,我最近遇到了你似乎遇到的同样问题。我可以提供我已经做的消除协议问题,但我希望这只会让你进入下一阶段的问题(密钥库/证书)。您的例外情况“默认协议无协议工厂:null”表示您的新连接器未引用ContextFactory,而ContextFactory又应指定协议。因此,如果不指定协议,则将其指定为null。虽然,我不明白为什么你复制的原始SSL连接器没有引起同样的问题,因为它似乎没有引用sslContextFactory id。
在父服务器配置中,您应该看到一个SslContextFactory。如果它在那里,复制/过去,唯一地更改它的id,并确保协议设置适当。我的Jetty类对我的应用程序来说是独一无二的,但是你应该能够根据Eclipse.org对Jetty类进行一些细微的修改,并解决协议问题,然后再进行下一步。
在服务器配置中,您的sslContextFactory应该类似于:
<New id="secondarySSLContextFactory" class="com.myapp.appserver.jetty.server.connector.ssl.RuntimeSslContextFactory">
<Set name="renegotiationAllowed">true</Set>
<Set name="needClientAuth">false</Set>
<Set name="wantClientAuth">false</Set>
<Set name="protocol">TLS</Set>
<Set name="secureRandomAlgorithm">SHA1PRNG</Set>
<Set name="excludeProtocols">
<Array type="java.lang.String">
<!-- Excluded to mitigate POODLE attack -->
<Item>SSLv3</Item>
</Array>
</Set>
</New>
然后,您新修改的连接器将类似于:
<Call name="addConnector">
<Arg>
<New id="sslConnector" class="org.eclipse.jetty.server.ServerConnector">
<Arg name="server"><Ref refid="Server" /></Arg>
<Arg name="acceptors" type="int"><Property name="jetty.ssl.acceptors" deprecated="ssl.acceptors" default="-1"/></Arg>
<Arg name="selectors" type="int"><Property name="jetty.ssl.selectors" deprecated="ssl.selectors" default="-1"/></Arg>
<Arg name="factories">
<Array type="org.eclipse.jetty.server.ConnectionFactory">
<!-- uncomment to support proxy protocol
<Item>
<New class="org.eclipse.jetty.server.ProxyConnectionFactory"/>
</Item>-->
<!-- REFERENCE TO CONTEXT FACTORY ID -->
<Item>
<New class="org.eclipse.jetty.server.SslConnectionFactory">
<Arg name="next">http/1.1</Arg>
<Arg name="sslContextFactory">
<Ref refid="secondarySSLContextFactory"/>
</Arg>
</New>
</Item>
</Array>
</Arg>
<Set name="host">1.2.3.5</Set>
<Set name="port">443</Set>
<Set name="idleTimeout"><Property name="jetty.ssl.idleTimeout" deprecated="ssl.timeout" default="30000"/></Set>
<Set name="soLingerTime"><Property name="jetty.ssl.soLingerTime" deprecated="ssl.soLingerTime" default="-1"/></Set>
<Set name="acceptorPriorityDelta"><Property name="jetty.ssl.acceptorPriorityDelta" deprecated="ssl.acceptorPriorityDelta" default="0"/></Set>
<Set name="acceptQueueSize"><Property name="jetty.ssl.acceptQueueSize" deprecated="ssl.acceptQueueSize" default="0"/></Set>
</New>
</Arg>
此外,如果您希望为备用IP使用备用SSL证书,则必须构建新的密钥库。上面的secondarySSLContextFactory是设置新密钥库路径和密码的位置。有许多参考资料可以帮助解决这个问题。但是,除了创建和分配新的证书+链/密钥库之外,我几乎没有任何帮助经验使服务器使用它们,但新连接器会响应。我在Jetty 9中找不到任何帮助。我希望我提供的内容有所帮助。