在同一个ubuntu EC2实例上部署多个平台服务器

时间:2014-07-22 06:35:28

标签: python ruby-on-rails ubuntu deployment amazon-ec2

我想在已部署的RAILS应用程序(带有nginx和unicorn)实例上部署python Flask服务器,该应用程序在ubuntu上运行,端口80用于http服务。

出于节省成本的原因,我想在不同端口的同一个ubuntu机器上运行一个内部python服务器,比如8888,让rails应用程序调用python服务器公开的api。

我在我的本地开发机器上做了这个实验,它运行良好。也就是说,我的rails服务器运行在localhost:3000,python服务器运行在localhost:8888。 rails服务器可以毫无问题地调用python api。但是在生产环境中,我正在努力使其发挥作用。问题是什么时候HTTP POST到“localhost:8888”有HTTP错误状态。这是行不通的。我确实在ubuntu机器上用IPTable打开了端口8888。

我想知道这是否可以在生产中进行部署。有什么建议我应该如何在生产中设置python服务器,以便它可以被rails服务器访问?

更新

deploy@app1:~$ netstat --listen
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 *:sunrpc                *:*                     LISTEN     
tcp        0      0 *:http                  *:*                     LISTEN     
tcp        0      0 *:ssh                   *:*                     LISTEN     
tcp        0      0 *:8888                  *:*                     LISTEN     
tcp        0      0 ip6-localhost:2812      *:*                     LISTEN     
tcp        0      0 *:54535                 *:*                     LISTEN     
tcp        0      0 ip6-localhost:6379      *:*                     LISTEN     
tcp6       0      0 [::]:sunrpc             [::]:*                  LISTEN     
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN     
tcp6       0      0 [::]:43095              [::]:*                  LISTEN     
udp        0      0 *:38271                 *:*                                
udp        0      0 *:741                   *:*                                
udp        0      0 ip6-localhost:968       *:*                                
udp        0      0 *:bootpc                *:*                                
udp        0      0 *:sunrpc                *:*                                
udp        0      0 app1:ntp                *:*                                
udp        0      0 ip6-localhost:ntp       *:*                                
udp        0      0 *:ntp                   *:*                                
udp6       0      0 [::]:741                [::]:*                             
udp6       0      0 [::]:40022              [::]:*                             
udp6       0      0 [::]:sunrpc             [::]:*                             
udp6       0      0 ip6-localhost:ntp       [::]:*                             
udp6       0      0 fe80::b4:ebff:fe34::ntp [::]:*                             
udp6       0      0 [::]:ntp                [::]:*                             
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ACC ]     STREAM     LISTENING     7438     /var/run/dbus/system_bus_socket
unix  2      [ ACC ]     STREAM     LISTENING     1583287  /srv/www/icon_sae/shared/sockets/unicorn.sock
unix  2      [ ACC ]     STREAM     LISTENING     5887     @/com/ubuntu/upstart
unix  2      [ ACC ]     STREAM     LISTENING     11658    /run/rpcbind.sock
unix  2      [ ACC ]     STREAM     LISTENING     7586     /var/run/acpid.socket
unix  2      [ ACC ]     SEQPACKET  LISTENING     6093     /run/udev/control

对Ubuntu主机中的localhost:8888的HTTP POST请求发出以下错误:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to target URL: <a href="http://localhost:8888/api/text/">http://localhost:8888/api/text/</a>.  If not click the link.

0 个答案:

没有答案