# Tunneling in capistrano twice

**URL:** <https://www.ruby-forum.com/t/tunneling-in-capistrano-twice/62720>\
**Category:** Rails\
**Created:** [June 7, 2006, 4:10pm UTC](https://www.ruby-forum.com/t/tunneling-in-capistrano-twice/62720 "2006-06-07T16:10:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![henster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a183cd/32.png) [@henster](https://www.ruby-forum.com/u/henster)\
**Post date:** [June 7, 2006, 4:10pm UTC](https://www.ruby-forum.com/t/tunneling-in-capistrano-twice/62720/1 "2006-06-07T16:10:56Z")

</div>

Hi there,

The default recipe expects you to be able to access your web server  
directly from your local machine.

On our web server, for security purposes, it is only possible to ssh  
to it through one particular ip (which is also a remote machine.)

The capistrano source is so compact and tidy it looks very hackable.  
But rather than messing around I thought I’d ask first if anyone else  
has any ideas?

Cheers  
Henry

---

<div class="post-metadata">

**Author:** ![henster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a183cd/32.png) [@henster](https://www.ruby-forum.com/u/henster)\
**Post date:** [June 7, 2006, 6:50pm UTC](https://www.ruby-forum.com/t/tunneling-in-capistrano-twice/62720/2 "2006-06-07T18:50:59Z")

</div>

Henry T. wrote:

> has any ideas?  
> Seems doable to me.

I’d probably leave the deploy task alone and create before\_deploy and  
after\_deploy tasks that did whatever you need to do. If you can tunnel  
through the intermediate host, this is pretty easy to do.

If you have more restrictive networking rules that block port  
forwarding, and you can run code on the intermediate server, you could  
just do

ssh user@particularip ‘cd /path/to && rake deploy’

My memory is that this will send the sudo prompt back to you, but I  
could be wrong about that. In some production environments, this might  
be the easiest way to go.

–

Ray

---

<div class="post-metadata">

**Author:** ![henster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a183cd/32.png) [@henster](https://www.ruby-forum.com/u/henster)\
**Post date:** [June 7, 2006, 7:13pm UTC](https://www.ruby-forum.com/t/tunneling-in-capistrano-twice/62720/3 "2006-06-07T19:13:12Z")

</div>

I remeber having had the same problem, but I don’t remember the  
solution. But why don’t you proxy to mongrel and serve the static  
files with apache ? That is much easier to setup and works very well  
for me.

---

<div class="post-metadata">

**Author:** ![henster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a183cd/32.png) [@henster](https://www.ruby-forum.com/u/henster)\
**Post date:** [June 7, 2006, 6:57pm UTC](https://www.ruby-forum.com/t/tunneling-in-capistrano-twice/62720/4 "2006-06-07T18:57:17Z")

</div>

Greetings,

I’ve set up apache as a proxy for my lightTPD server as describe in JDD  
essay: [http://duncandavidson.com/essay/2006/01/railsonapache](http://duncandavidson.com/essay/2006/01/railsonapache)

Everything works great except if I try to access my site like this:  
[http://softdist6.berkeley.edu](http://softdist6.berkeley.edu)

Then my webrowser tries to download the dispatch.fcgi from the webdir of  
my app. I have no idea why this is happening. If I do  
softdist6.berkeley.edu/all or any sub directory of  
softdist6.berkeley.edu  
then everything works fine.

My lighthttpd.conf and vhost.conf files are below. Anyone have any  
ideas?

[lightTPD]  
server.document-root = “/srv/www/ror-apps/software\_central/public”  
server.modules = (“mod\_rewrite”, “mod\_accesslog”, “mod\_fastcgi”)  
server.port = 81  
server.username = “wwwrun”  
server.groupname = “www”  
server.pid-file = CWD + “/tmp/lighttpd.pid”  
accesslog.filename = CWD + “/log/access\_log”  
server.errorlog = CWD + “/log/error\_log”  
server.indexfiles = ( “index.html” )

mimetype.assign = (  
“.css” =\> “text/css”,  
“.gif” =\> “image/gif”,  
“.html” =\> “text/html”,  
“.jpeg” =\> “image/jpeg”,  
“.jpg” =\> “image/jpeg”,  
“.js” =\> “text/javascript”,  
“.pdf” =\> “application/pdf”,  
“.png” =\> “image/png”,  
“.txt” =\> “text/plain”,  
)

var.appname = “/srv/www/ror-apps/software\_central”

$HTTP[“host”] == “softdist6.berkeley.edu” {  
server.document-root = CWD + “/public”  
url.rewrite = ( “^/$” =\> “index.html”, “^([^.]+)$” =\> “$1.html” )  
server.error-handler-404 = “/dispatch.fcgi”  
fastcgi.server = ( “.fcgi” =\>  
( “localhost” =\>  
( “min-procs” =\> 5,  
“max-procs” =\> 5,  
“socket” =\> CWD + “/tmp/sockets/fcgi.socket”,  
“bin-path” =\> CWD + “/public/dispatch.fcgi”,  
“bin-environment” =\> ( “RAILS\_ENV” =\> “development” )  
)  
)  
)  
}  
[/lightTPD]

[apache]  
\<VirtualHost \*:80\>  
ServerName softdist6.berkeley.edu  
DocumentRoot /srv/www/htdocs/softdist6  
ProxyPass /wsspurch !

ProxyPass /i [http://softdist6.berkeley.edu:81/](http://softdist6.berkeley.edu:81/)  
ProxyPassReverse / [http://softdist6.berkeley.edu:81](http://softdist6.berkeley.edu:81)  
ProxyPreserveHost on

[/apache]

---

<div class="post-metadata">

**Author:** ![henster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a183cd/32.png) [@henster](https://www.ruby-forum.com/u/henster)\
**Post date:** [June 7, 2006, 7:35pm UTC](https://www.ruby-forum.com/t/tunneling-in-capistrano-twice/62720/5 "2006-06-07T19:35:35Z")

</div>

Well, if I can’t fix this problem then I may consider doing that, but  
for the time being I’d like find a working solution for lightTPD.

---

<div class="post-metadata">

**Author:** ![henster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a183cd/32.png) [@henster](https://www.ruby-forum.com/u/henster)\
**Post date:** [June 7, 2006, 9:32pm UTC](https://www.ruby-forum.com/t/tunneling-in-capistrano-twice/62720/6 "2006-06-07T21:32:32Z")

</div>

“Why would you prefer to use three things when two will do?”

???

Who is using 3 things? There are two options that were discussed:

1. Apache being the proxy for lightTPD
2. Apache being the proxy for mongrel

At least that’s how I understood the suggestion.

-Steven

---

<div class="post-metadata">

**Author:** ![henster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a183cd/32.png) [@henster](https://www.ruby-forum.com/u/henster)\
**Post date:** [June 7, 2006, 9:19pm UTC](https://www.ruby-forum.com/t/tunneling-in-capistrano-twice/62720/7 "2006-06-07T21:19:35Z")

</div>

Why would you prefer to use three things when two will do?

–  
– Tom M.

---

<div class="post-metadata">

**Author:** ![henster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a183cd/32.png) [@henster](https://www.ruby-forum.com/u/henster)\
**Post date:** [June 7, 2006, 10:38pm UTC](https://www.ruby-forum.com/t/tunneling-in-capistrano-twice/62720/8 "2006-06-07T22:38:17Z")

</div>

On Jun 7, 2006, at 11:31 AM, Steven H. wrote:

> “Why would you prefer to use three things when two will do?”
> 
> ???
> 
> Who is using 3 things? There are two options that were discussed:
> 
> 1. Apache being the proxy for lightTPD

Lighty then passes Rails requests to FastCGI, which makes it three.

> 1. Apache being the proxy for mongrel

Where mongrel handles the Rails requests, making it two.

–  
– Tom M.
