# Help with capistrano and nginx

**URL:** <https://www.ruby-forum.com/t/help-with-capistrano-and-nginx/108262>\
**Category:** Rails\
**Created:** [July 1, 2007, 7:23am UTC](https://www.ruby-forum.com/t/help-with-capistrano-and-nginx/108262 "2007-07-01T07:23:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 1, 2007, 7:23am UTC](https://www.ruby-forum.com/t/help-with-capistrano-and-nginx/108262/1 "2007-07-01T07:23:47Z")

</div>

I’m using nginx with capistrano to deploy my Rails app and I’m having  
a hard time getting the maintenance capistrano task  
(deploy:web:disable) to work like I want. I want nginx to redirect all  
requests to public/maintenance-on.html if the file exists, however,  
since I use stylesheets and images on this file, nginx should serve  
them. Here’s what I have so far on nginx.conf:

if (-f $document\_root/public/maintenance-on.html) {  
rewrite ^(.\*)$ /maintenance-on.html last;  
break;  
}

How could I make this not match urls containing /stylesheets/ and /  
images/?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 1, 2007, 9:44am UTC](https://www.ruby-forum.com/t/help-with-capistrano-and-nginx/108262/2 "2007-07-01T09:44:35Z")

</div>

this question would probably be best answered on the deployment forum.  
here u go:

[http://www.ruby-forum.com/forum/23](http://www.ruby-forum.com/forum/23)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 2, 2007, 8:49am UTC](https://www.ruby-forum.com/t/help-with-capistrano-and-nginx/108262/3 "2007-07-02T08:49:01Z")

</div>

Thanks, but the group seems kinda dead. None else has a similar  
problem?

On Jul 1, 4:44 am, Shai R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 2, 2007, 10:42am UTC](https://www.ruby-forum.com/t/help-with-capistrano-and-nginx/108262/4 "2007-07-02T10:42:15Z")

</div>

Not sure if this helps at all, but taking a shot in the dark (I didn’t  
read  
your original post):  
[http://blog.mcconnachie.ca/2007/5/28/capistrano-nginx-and-mongrel-cluster-deployment](http://blog.mcconnachie.ca/2007/5/28/capistrano-nginx-and-mongrel-cluster-deployment)

Cheers,  
Walter

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 2, 2007, 1:22pm UTC](https://www.ruby-forum.com/t/help-with-capistrano-and-nginx/108262/5 "2007-07-02T13:22:57Z")

</div>

> How could I make this not match urls containing /stylesheets/ and /  
> images/?

will modifiying the matching regexp work?

> if (-f $document\_root/public/maintenance-on.html) {  
> instead of  
> rewrite ^(.\*)$ /maintenance-on.html last;

# UNTESTED

rewrite ^([^(stylesheets|images)]\*)$

> break;  
> }

or something like that…  
?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 2, 2007, 10:48pm UTC](https://www.ruby-forum.com/t/help-with-capistrano-and-nginx/108262/6 "2007-07-02T22:48:13Z")

</div>

Thanks, working on the regexp would probably work. In this case it  
almost worked, the maintenance is displayed on the index, and the  
images work, but other internal pages still show up.

Any ideas?

On Jul 2, 8:22 am, Shai R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 2, 2007, 12:07pm UTC](https://www.ruby-forum.com/t/help-with-capistrano-and-nginx/108262/7 "2007-07-02T12:07:25Z")

</div>

Not really what I’m looking for. I’m starting to think there’s no way  
to do this, hasn’t anybody ever wanted to add images to their  
maintenance pages?

On Jul 2, 5:41 am, “Walter McGinnis” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
