gpt4 book ai didi

ssl - 将 Jetty 9 和 jetty.xml 与 BaseX 结合使用

转载 作者:太空宇宙 更新时间:2023-11-03 14:10:01 25 4
gpt4 key购买 nike

在 Jetty 8 中,覆盖标准服务器端口并在自定义 jetty.xml 文件中添加 SSL 连接器相当容易,如下所示:

<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<Set name="port">8984</Set>
<Set name="confidentialPort">8986</Set>
</New>
</Arg>
</Call>

<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
<Set name="Port">8986</Set>
<!-- keystore, password, keyPassword, ... -->
</New>
</Arg>
</Call>
</Configure>

由于 Jetty 9 不再接受此配置,我检查了 Jetty documentation和相关的 StackOverflow 问题(如 How to override jetty.xml with jetty.port)没有成功。

如何重写配置以在 Jetty 9 中执行相同的操作?

最佳答案

几乎没有理由再使用 Jetty 9 编辑 XML 文件。

使用 Jetty 9 模块系统和 ${jetty.base} 概念。

$ cd /opt/jetty
$ tar -zxvf jetty-distribution-9.3.3.v20150827.tar.gz
$ mkdir my.base
$ cd my.base
$ java -jar ../jetty-distribution-9.3.3.v20150827/start.jar \
--add-to-start=http,https,deploy,webapp
INFO: server initialised (transitively) in ${jetty.base}/start.ini
INFO: http initialised in ${jetty.base}/start.ini
INFO: ssl initialised (transitively) in ${jetty.base}/start.ini
INFO: https initialised in ${jetty.base}/start.ini
INFO: webapp initialised in ${jetty.base}/start.ini
INFO: deploy initialised in ${jetty.base}/start.ini
DOWNLOAD: http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/plain/jetty-server/src/test/config/etc/keystore?id=master to ${jetty.base}/etc/keystore
MKDIR: ${jetty.base}/webapps
INFO: Base directory was modified
$ ls -laF$ ls -laF
total 48
drwxrwxr-x. 4 joakim joakim 4096 Sep 23 06:01 ./
drwxr-xr-x. 22 joakim joakim 12288 Sep 23 06:00 ../
drwxrwxr-x. 2 joakim joakim 4096 Sep 23 06:01 etc/
-rw-rw-r--. 1 joakim joakim 5009 Sep 23 06:01 start.ini
drwxrwxr-x. 2 joakim joakim 4096 Sep 23 06:01 webapps/

此时:

  • 用您的 SSL keystore 替换 etc/keystore 文件。
  • 编辑 start.ini 用于:
    • 您的 http 端口 (jetty.http.port)
    • 你的 https 端口 (jetty.https.port)
    • 和您的各种 SslContext/keystore 值(参见以 jetty.sslContext. 开头的键)

完成后,运行 Jetty ..

$ cd /opt/jetty/my.base
$ java -jar ../jetty-distribution-9.3.3.v20150827/start.jar
2015-09-23 06:05:40.619:INFO::main: Logging initialized @272ms
2015-09-23 06:05:40.764:INFO:oejs.Server:main: jetty-9.3.3.v20150827
2015-09-23 06:05:40.779:INFO:oejdp.ScanningAppProvider:main: Deployment monitor [file:///home/joakim/code/jetty/distros/my.base/webapps/] at interval 1
2015-09-23 06:05:40.790:INFO:oejs.ServerConnector:main: Started ServerConnector@1718d616{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
2015-09-23 06:05:40.810:INFO:oejus.SslContextFactory:main: x509=X509@7e0babb1(jetty,h=[jetty.eclipse.org],w=[]) for SslContextFactory@6debcae2(file:///home/joakim/code/jetty/distros/my.base/etc/keystore,file:///home/joakim/code/jetty/distros/my.base/etc/keystore)
2015-09-23 06:05:40.810:INFO:oejus.SslContextFactory:main: x509=X509@5ba23b66(mykey,h=[],w=[]) for SslContextFactory@6debcae2(file:///home/joakim/code/jetty/distros/my.base/etc/keystore,file:///home/joakim/code/jetty/distros/my.base/etc/keystore)
2015-09-23 06:05:41.026:INFO:oejs.ServerConnector:main: Started ServerConnector@305fd85d{SSL,[ssl, http/1.1]}{0.0.0.0:8443}
2015-09-23 06:05:41.027:INFO:oejs.Server:main: Started @680ms

想知道您的服务器配置是什么样的吗?运行这个...

$ cd /opt/jetty/my.base
$ java -jar ../jetty-distribution-9.3.3.v20150827/start.jar --list-config

关于ssl - 将 Jetty 9 和 jetty.xml 与 BaseX 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32734920/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com