java 在远程机器上启用端口 8443 以进行 https 访问
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10025893/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Enable port 8443 on remote machine for https access
提问by Manohar Bhattarai
There is a tomcat6 server which is enabled for https access on port 8443 with settings on <connector>
tag of server.xml file. It is as shown below:
有一个 tomcat6 服务器,它启用了端口 8443 上的 https 访问,并在<connector>
server.xml 文件的标签上进行了设置。如下图所示:
<Connector port="8443"
SSLEnabled="true"
maxThreads="150"
minSpareThreads="25"
maxSpareThreads="75"
enableLookups="true"
disableUploadTimeout="true"
acceptCount="100"
debug="0"
connectionTimeout="60000"
scheme="https"
secure="true"
clientAuth="false"
sslProtocol="TLS"
keystoreFile="/etc/tomcat6/.keystore"
keystorePass="changeit"
/>
I am trying to access port 8443 with https on a remote machine using this server via java code. I am getting java.net.ConnectException: Connection refused
on catalina.out log. This exception is generated on the line connection.getResponseCode();
of the java code. It seems that the port is not open on the remote machine. I am able to access port 8443 on the server itself without any exception. Remote machine has no tomcat installed.
我正在尝试通过 java 代码使用此服务器在远程机器上使用 https 访问端口 8443。我正在java.net.ConnectException: Connection refused
访问 catalina.out 日志。这个异常是connection.getResponseCode();
在java代码行上产生的。远程机器上的端口似乎没有打开。我可以毫无例外地访问服务器本身的端口 8443。远程机器没有安装tomcat。
I want to open that port on the remote machine for https access by the java code. I am using ubuntu server 10.04 LTS as both server and remote machine. I cannot use firewalls(ufw or iptables due to restriction). I can use stunnel4 on both the machines.
我想在远程机器上打开该端口以通过 java 代码进行 https 访问。我使用 ubuntu 服务器 10.04 LTS 作为服务器和远程机器。我不能使用防火墙(ufw 或 iptables 由于限制)。我可以在两台机器上使用 stunnel4。
回答by George Sun
First of all, please use: sudo nmap -v -A localhost
to check whether port 8443 is open on the remote machine. The result should be something like:
首先请使用:sudo nmap -v -A localhost
检查远程机器上的8443端口是否打开。结果应该是这样的:
Starting Nmap 5.21 ( http://nmap.org ) at 2012-06-26 04:27 UTC
NSE: Loaded 36 scripts for scanning.
Initiating SYN Stealth Scan at 04:27
Scanning localhost (127.0.0.1) [1000 ports]
Discovered open port 22/tcp on 127.0.0.1
Completed SYN Stealth Scan at 04:27, 0.02s elapsed (1000 total ports)
Initiating Service scan at 04:27
Scanning 1 service on localhost (127.0.0.1)
Completed Service scan at 04:27, 0.01s elapsed (1 service on 1 host)
if information for port 8443 is not appearing, something like:
如果没有出现端口 8443 的信息,例如:
Discovered open port 8443/tcp on 127.0.0.1
It means port 8443 is not enabled, you need to do something for it.
这意味着端口 8443 未启用,您需要为它做一些事情。