0

I have a Rails application deployed on Apache-Passenger which runs fine when access from localhost, but doesn't run via remote access.

Let's say the server name is server.name.com. The server info is -

[kbc@server KBC]$ uname -a
Linux server.name.com 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
[kbc@server KBC]$ cat /etc/issue
CentOS release 6.5 (Final)
Kernel \r on an \m

When I do
[kbc@server ]$ curl http://localhost:3000/, it returns the home page for the application.

But when I try to access the Rails app from my laptop, I get the following error -

→ curl http://server.name.com:3000/
curl: (7) Failed to connect to server.name.com port 3000: Connection refused

To check if I can access the server, I tried -

→ ping server.name.com:3000
ping: cannot resolve server.name.com:3000: Unknown host

But, I can ping the server by -

→ ping server.name.com
PING server.name.com (@.@.@.@): 56 data bytes
64 bytes from @.@.@.@: icmp_seq=0 ttl=61 time=1.526 ms
64 bytes from @.@.@.@: icmp_seq=1 ttl=61 time=6.624 ms

Here is the Passenger configuration -

<VirtualHost *:3000>
   ServerName server.name.com
   ServerAlias server.name.com
   DocumentRoot /home/kbc/KBC/public
   <Directory /home/kbc/KBC/public>
      AllowOverride all
      Options -MultiViews
   </Directory>
  ErrorLog /var/log/httpd/kbc_error.log
  CustomLog /var/log/httpd/kbc_access.log common
</VirtualHost>

NameVirtualHost *:3000
PassengerPreStart https://server.name.com:3000/

and

LoadModule passenger_module /home/kbc/.rvm/gems/ruby-2.3.0@kbc/gems/passenger-5.0.30/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
        PassengerRoot /home/kbc/.rvm/gems/ruby-2.3.0@kbc/gems/passenger-5.0.30
        PassengerDefaultRuby /home/kbc/.rvm/wrappers/ruby-2.3.0/ruby
        PassengerRuby /home/kbc/.rvm/wrappers/ruby-2.3.0/ruby
        PassengerMaxPoolSize 5
        PassengerPoolIdleTime 90
        PassengerMaxRequests 10000
</IfModule>

Passenger-status info -

[kbc@server ]$ passenger-status
Version : 5.0.30
Date    : 2016-10-17 11:30:08 -0400
Instance: bKUJ0ptp (Apache/2.2.15 (Unix) DAV/2 Phusion_Passenger/5.0.30)

----------- General information -----------
Max pool size : 5
App groups    : 1
Processes     : 1
Requests in top-level queue : 0

----------- Application groups -----------
/home/kbc/KBC:
  App root: /home/kbc/KBC
  Requests in queue: 0
  * PID: 5696    Sessions: 0       Processed: 1       Uptime: 1m 45s
    CPU: 0%      Memory  : 38M     Last used: 1m 45s ago

What am I doing wrong? Please let me know if you need more information.

Jatin Ganhotra
  • 6,825
  • 6
  • 48
  • 71

2 Answers2

2

This sounds like a connectivity problem, not a Passenger/Apache problem. The host you're running the server on may not accept inbound connections on port 3000 (due to iptables, firewall, or security group access control rules).

Take a look at apache not accepting incoming connections from outside of localhost and Apache VirtualHost and localhost, for instance.

Community
  • 1
  • 1
gmcnaughton
  • 2,233
  • 1
  • 21
  • 28
1

@Jatin, could you please post the apache main configuration ? (/etc/apache2/apache2.conf or similar)

Also, please provide the output of the following :

sudo netstat -nl
sudo iptables -L

Just for the record, the ping utility can only test connectivity at the IP layer, meaning that it can tell you whether the host at a given IP is responding. It cannot, however, tell you if a specific TCP port is open on the remote system.

Testing TCP connectivity can be achieved easily with telnet or netcat :

telnet server.name.com 3000

If you get something like :

Trying @.@.@.@...
Connected to server.name.com.
Escape character is '^]'.

then this means you can correctly access the TCP endpoint, eliminating any possibility of network-related issues. In other words, if this works, you probably have a configuration problem with Apache.

Eresse
  • 108
  • 1
  • 6