简体   繁体   中英

Setup Apache reverse-proxy for rails app running at port 3000

I manage a small VPS running several PHP/MySQL websites. It's running CentOS (albeit a slightly modified VSP version x86). All is working well. However, now I would like to run a Rails 3 application on a certain domain hosted on my VPS. The thing is, the application requires Rails 3 which isn't yet supported by cPanel. If I ssh to the server and run rails s in the app's folder it runs smoothly, and I can access it at siegedog.com:3000 . However, I would like to redirect all requests to siegedog.com to port 3000.

I've read that this would assume setting up a reverse proxy that would redirect all the requests it gets for siegedog to Mongrel, which should be running on port 3000. I've checked out a lot of tutorials but most of them were confusing and/or quite out-of-date.

I have also tried Passenger. However, editing my httpd.conf is disallowed by cpanel. So I used a separate file that gets included there and added the extra configuration parameters in a remote file, only to get the Default server page problem, and no errors in the apache error log.

Well, thanks to John Douthat's I managed to do set up my app pretty easily using the following .htaccess document:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^siegedog\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.siegedog\.com$
RewriteRule ^(.*) "http\:\/\/127\.0\.0\.1\:3000\/$1" [P,L]

Also, to start it from an ssh connection I called:

nohup rails s &

in the rails application's root. All is well now!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM