繁体   English   中英

Ubuntu EC2服务器未连接到Tomcat7和GeoServer的Public-IP端口8080

[英]Ubuntu EC2 Server not connecting to Public-IP port 8080 for Tomcat7 & GeoServer

我们有一台运行Flask应用程序的服务器,该服务器使用Tomcat7下的GeoServer在内部向应用程序本身提供地图数据,并通过WMS在外部将其提供给经过身份验证的用户。

一切工作正常,直到一些停止工作的小代码编辑/重新加载,命令行更新/升级和重新启动(包括从EC2控制台重新启动)之后。

经过一番挖掘和调试之后,似乎系统的所有元素都可以正常工作,但是通过端口8080对Tomcat7和GeoServer的关键请求没有连接并且没有超时(通常在大约2分钟后)。

我查看了许多有关类似问题的在线帮助,并检查,实施和测试了其中的一些建议,但似乎没有什么可以消除障碍。

我不是专家(尽管我在此过程中学到了很多知识!),但据我所知,我已经尝试了所有显而易见的建议事项。

我现在似乎对此进行了盘旋(即无处可寻),因此,非常感激收到有关我接下来可能尝试的任何建议。

背景信息:

  • 具有公共IP和私有IP,无弹性IP或负载均衡器的EC2实例
  • Ubuntu Xenial 16.04,Apache 2.4.18,Tomcat7,GeoServer 2.11.0
  • 安全组使用以下规则配置并应用于EC2实例:

     INBOUND RULES Type Protocol Port Range Source HTTP TCP 80 0.0.0.0/0 HTTP TCP 80 ::/0 Custom TCP Rule TCP 8080 xxxx/32 Custom TCP Rule TCP 5432 xxxx/32 SSH TCP 22 xxxx/32 Custom TCP Rule TCP 443 0.0.0.0/0 Custom TCP Rule TCP 443 ::/0 OUTBOUND RULES Type Protocol Port Range Destination All traffic All All 0.0.0.0/0 
  • 域名将Ok解析为公共IP

  • 防火墙已禁用-sudo ufw状态返回“状态:不活动”
  • 可以从PuTTY SSH到服务器
  • 可以使用http:// Public-IP:8080 / geoserver / web /从浏览器访问GeoServer Web Admin
  • 检查了这篇文章,并更新了/usr/share/tomcat7/bin/catalina.sh添加以下内容:

     JAVA_OPTS=" $JAVA_OPTS -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Ad=true " 
  • 检查了这篇文章并更新了/etc/tomcat7/server.xml来制作连接器字符串:

     <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" URIEncoding="UTF-8" redirectPort="8443" address="0.0.0.0" useIPVHosts="true" /> 
  • 使用netstat检查了不同端口上正在侦听的内容:

     root@ip-xxx-xx-xx-xx:/var/log/apache2# netstat -ltnpa | grep -i --colour LISTEN tcp 0 0 127.0.0.1:587 0.0.0.0:* LISTEN 1438/sendmail: MTA: tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 1437/java tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1208/sshd tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 1350/postgres tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1438/sendmail: MTA: tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN 1437/java tcp6 0 0 :::80 :::* LISTEN 1456/apache2 tcp6 0 0 :::22 :::* LISTEN 1208/sshd tcp6 0 0 :::5432 :::* LISTEN 1350/postgres tcp6 0 0 :::443 :::* LISTEN 1456/apache2 

观察到的问题

调试显示,Flask应用程序将格式正确的请求发送到http:// Public-IP:8080 / geoserver / roar / wms ?...,但对urllib2.urlopen (req)的调用引发了异常'[Errno 110]连接超时out”,这是在abort(404)中报告的。

如果我获取请求字符串(使用Public-IP)并将其粘贴到浏览器中,它将起作用。 请注意,这是http://而不是https://-不知道这是否有意义-请参阅以下有关使用https://的说明

如果我使用Public-IP从命令行尝试cURL,则会收到超时消息:

    connect to Public-IP port 8080 failed: Connection timed out
    * Failed to connect to Public-IP port 8080: Connection timed out
    * Closing connection 0

如果我使用本地主机从命令行尝试cURL,例如到端口8080上的Tomcat7,它将起作用…

    $ curl -v localhost:8080/
    *   Trying 127.0.0.1...
    * Connected to localhost (127.0.0.1) port 8080 (#0)
    > GET / HTTP/1.1
    > Host: localhost:8080
    > User-Agent: curl/7.47.0
    > Accept: */*
    >
    < HTTP/1.1 200 OK
    < Server: Apache-Coyote/1.1
    < Accept-Ranges: bytes
    < ETag: W/"1896-1493801565000"
    < Last-Modified: Wed, 03 May 2017 08:52:45 GMT
    < Content-Type: text/html
    < Content-Length: 1896
    < Date: Fri, 22 Jun 2018 09:39:46 GMT
    <
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <title>Apache Tomcat</title>
    </head>
    <body>
    <h1>It works !</h1>
    etc…….

如果我在命令行中使用Private-IP尝试cURL,例如在端口8080上的Tomcat7,它将起作用……

    $ curl -v Private-IP:8080/
    *   Trying Private-IP...
    * Connected to Private-IP (Private-IP) port 8080 (#0)
    > GET / HTTP/1.1
    > Host: Private-IP:8080
    > User-Agent: curl/7.47.0
    > Accept: */*
    >
    < HTTP/1.1 200 OK
    < Server: Apache-Coyote/1.1
    < Accept-Ranges: bytes
    < ETag: W/"1896-1493801565000"
    < Last-Modified: Wed, 03 May 2017 08:52:45 GMT
    < Content-Type: text/html
    < Content-Length: 1896
    < Date: Fri, 22 Jun 2018 09:42:30 GMT
    <
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <title>Apache Tomcat</title>
    </head>
    <body>
    <h1>It works !</h1>
    etc…….

如果我只是尝试使用带有域名或Public-IP的http://从浏览器连接到端口8080,我将得到Tomcat7 index.html“有效!” 响应。

如果我使用https://尝试相同的操作,我将从Mozilla获得以下信息…

   Secure Connection Failed
   An error occurred during a connection to Public-IP:8080. SSL received a record that
   exceeded the maximum permissible length. Error code: SSL_ERROR_RX_RECORD_TOO_LONG
       The page you are trying to view cannot be shown because the authenticity of the received data
       could not be verified.

并从IE(建议的设置打开)…

    This page can’t be displayed
    Turn on TLS 1.0, TLS 1.1, and TLS 1.2 in Advanced settings and try connecting to
    https://Public-IP:8080  again. If this error persists, it is possible that this site uses an
    unsupported protocol or cipher suite such as RC4 (link for the details), which is not considered
    secure. Please contact your site administrator.

和Chrome浏览器…

    This site can’t provide a secure connection
    Public-IP sent an invalid response.
    Try running Windows Network Diagnostics.
    ERR_SSL_PROTOCOL_ERROR

如果Flask应用程序和GeoServer在同一EC2服务器上运行,则它们应通过localhost而不是私有IP或公共IP相互通信

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM