簡體   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