samedi 12 avril 2014

node.js - AWS EC2 port ouvert, mais toujours pas accessible - Stack Overflow


I have port TCP 3000 enabled, it even shows enabled under the EC2 security settings.


Although I can not telnet into my server via that port, I'm getting Could not open connection to the host, on port 3000: Connect failed.


I'm running an Ubuntu 12.04 AWS EC2 Micro instance in Oregon.


I'm running apache on the server to host http(s) (80/443) traffic and am trying to host an additional app through port 3000 via nodejs express.


Here is my Apache sites-enabled file:


<VirtualHost *:80>
ServerAdmin name@domain.com
ServerName www.domain.com
ServerAlias www.domain.com

DocumentRoot /var/www/

ProxyRequests off

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

<Location />
ProxyPass http://localhost:80/
ProxyPassReverse http://localhost:80/
</Location>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin name@domain.com
ServerName lobby.domain.com
ServerAlias lobby.domain.com

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

<Location />
ProxyPass http://localhost:3000/
ProxyPassReverse http://lobby.domain.com/
</Location>

</VirtualHost>



This is what you want on your reverse proxy configs:


NameVirtualHost *:80

<VirtualHost *:80>
ServerAdmin name@domain.com
ServerName www.domain.com
ServerAlias www.domain.com

DocumentRoot /var/www/

</VirtualHost>

<VirtualHost *:80>
ServerAdmin name@domain.com
ServerName lobby.domain.com
ServerAlias lobby.domain.com

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

<Location />
ProxyPass http://127.0.0.1:3000/
ProxyPassReverse http://127.0.0.1:3000/
</Location>

</VirtualHost>

Make sure you enable the apache proxy modules, from the command line:


a2enmod proxy
a2enmod proxy_connect
a2enmod proxy_http
a2enmod proxy_balancer
service apache2 restart



Make sure you are binding your application on 0.0.0.0 instead of 127.0.0.1 or localhost. It sounds like your application is not listening to IP addresses outside of the server.


(Also make sure your node.js application is running too)


To listed on 0.0.0.0 you need to so something like this in your application:


var app = connect().use(connect.static('public')).listen(3000, "0.0.0.0");


I have port TCP 3000 enabled, it even shows enabled under the EC2 security settings.


Although I can not telnet into my server via that port, I'm getting Could not open connection to the host, on port 3000: Connect failed.


I'm running an Ubuntu 12.04 AWS EC2 Micro instance in Oregon.


I'm running apache on the server to host http(s) (80/443) traffic and am trying to host an additional app through port 3000 via nodejs express.


Here is my Apache sites-enabled file:


<VirtualHost *:80>
ServerAdmin name@domain.com
ServerName www.domain.com
ServerAlias www.domain.com

DocumentRoot /var/www/

ProxyRequests off

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

<Location />
ProxyPass http://localhost:80/
ProxyPassReverse http://localhost:80/
</Location>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin name@domain.com
ServerName lobby.domain.com
ServerAlias lobby.domain.com

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

<Location />
ProxyPass http://localhost:3000/
ProxyPassReverse http://lobby.domain.com/
</Location>

</VirtualHost>


This is what you want on your reverse proxy configs:


NameVirtualHost *:80

<VirtualHost *:80>
ServerAdmin name@domain.com
ServerName www.domain.com
ServerAlias www.domain.com

DocumentRoot /var/www/

</VirtualHost>

<VirtualHost *:80>
ServerAdmin name@domain.com
ServerName lobby.domain.com
ServerAlias lobby.domain.com

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

<Location />
ProxyPass http://127.0.0.1:3000/
ProxyPassReverse http://127.0.0.1:3000/
</Location>

</VirtualHost>

Make sure you enable the apache proxy modules, from the command line:


a2enmod proxy
a2enmod proxy_connect
a2enmod proxy_http
a2enmod proxy_balancer
service apache2 restart


Make sure you are binding your application on 0.0.0.0 instead of 127.0.0.1 or localhost. It sounds like your application is not listening to IP addresses outside of the server.


(Also make sure your node.js application is running too)


To listed on 0.0.0.0 you need to so something like this in your application:


var app = connect().use(connect.static('public')).listen(3000, "0.0.0.0");

0 commentaires:

Enregistrer un commentaire