Reputation: 13819
I deploy an RoR application to my server, with an extra Apache2 virtual host file:
<VirtualHost *:80>
# ServerName ubuntu
DocumentRoot /var/www/myapp/current/public
PassengerEnabled off
ProxyPass / http://127.0.0.1:9051
ProxyPassReverse / http://127.0.0.1:9051
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect all requests to the maintenance page if present
RewriteCond %{REQUEST_URI} !\.(css|gif|jpg|png)$
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [L]
</IfModule>
</VirtualHost>
and I start it using Passenger:
passenger start -a 127.0.0.1 -p 9051 -e production -d
It's a Ubuntu server:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04 LTS
Release: 12.04
Codename: precise
And the port is listening:
plee@ubuntu:~$ sudo lsof -i :9051
[sudo] password for plee:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 1016 plee 4u IPv4 168135 0t0 TCP localhost:9051 (LISTEN)
nginx 1017 plee 4u IPv4 168135 0t0 TCP localhost:9051 (LISTEN)
nginx 1017 plee 5u IPv4 225556 0t0 TCP localhost:9051->localhost:44586 (ESTABLISHED)
ruby 1018 plee 5u IPv4 225555 0t0 TCP localhost:44586->localhost:9051 (ESTABLISHED)
The problem is that, my app can only be accessed by http://localhost:9051
If I try to connect from another machine using the server's IP address: http://10.50.10.75:9051
Google Chrome gives me:
Google Chrome could not connect to 10.50.10.75:9051
Please help me out!
Thanks.
Upvotes: 0
Views: 1816
Reputation: 16779
You're trying too hard. If you're on a server like you are, with apps running on various ports (and they're probably dev / staging, right?), and you simply want to access this app at port :9501, then the easy way is to ditch Apache. All you need is passenger, and you start it like this, without the -a option:
passenger start -p 9051 -e production -d
That's it; you're done. (You might want to make sure that your firewall, probably ufw, is not blocking that port, but that's the only other thing to test if you're still having problems.)
And a final piece of advice: Don't use a browser to test this kind of thing. Use curl. E.g.,
curl --head http://x.y.z.a:9051
Upvotes: 2
Reputation: 9146
If you want to access it access it on another port you need to add a virtualhost enty for that also you need to make apache listen to that port along with port 80
Here is what you need
#set the mod_passenger path **MAY BE DIFFERENT FOR YOU**
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.1.3/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.1.3
PassengerRuby /usr/bin/ruby1.8
#Listen to port 9501
Listen 9501
#add virtual host enty for port 9501
<VirtualHost *:9501>
ServerName myservername
DocumentRoot /var/www/tut/public
<Directory /var/www/tut/public>
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
NOTE:No need to start the passenger from command line now, this should already do it.
This worked for me.
Upvotes: 0