Nginx: passenger_enabled on; in location vs. server block

1,547 views
Skip to first unread message

Nickolay Kolev

unread,
Apr 22, 2009, 5:11:38 AM4/22/09
to Phusion Passenger Discussions
Hi all,

we are currently testing Passenger for Nginx (0.6.36) and it seems be
working lovely. Thanks for the great release!

We started out using a config similar to this:

server {
listen 80;
server_name www.example.com;
root /var/www/example/current/public;
passenger_enabled on;
}

I then wanted to configure Nginx to send Expires headers for static
files and added a location block to the server block:

server {
listen 80;
server_name www.example.com;
root /var/www/example/current/public;
passenger_enabled on;

location / {
...
}

}

At this point nginx started returning 403 responses for the virtual
host. Having directives in the location block or leaving it empty made
no difference. As long as there was a location / block within the
server block nginx would return 403 for any request.

We settled on something like this:

server {
listen 80;
server_name www.example.com;
root /var/www/example/current/public;

location / {
passenger_enabled on;
...
}

}

This works - all requests are processed correctly and the directives
which add Expires headers work. Testing with ab from a remote host
however show that the second configuration (passenger_enabled on; in
the location bock) can handle much less concurrent traffic. Is there
some rationale behind this?

Many thanks for any pointers ina advance!

Best,
Nickolay

Wiktor Schmidt

unread,
Apr 29, 2009, 3:36:53 AM4/29/09
to Phusion Passenger Discussions
We have the same problem - that is the reason for those 403?

On Apr 22, 11:11 am, Nickolay Kolev <nmko...@gmail.com> wrote:
> Hi all,
>
> we are currently testing Passenger forNginx(0.6.36) and it seems be
> working lovely. Thanks for the great release!
>
> We started out using a config similar to this:
>
> server {
>   listen 80;
>   server_namewww.example.com;
>   root /var/www/example/current/public;
>   passenger_enabled on;
>
> }
>
> I then wanted to configureNginxto sendExpiresheaders for static
> files and added a location block to the server block:
>
> server {
>   listen 80;
>   server_namewww.example.com;
>   root /var/www/example/current/public;
>   passenger_enabled on;
>
>   location / {
>     ...
>   }
>
> }
>
> At this pointnginxstarted returning 403 responses for the virtual
> host. Having directives in the location block or leaving it empty made
> no difference. As long as there was a location / block within the
> server blocknginxwould return 403 for any request.
>
> We settled on something like this:
>
> server {
>   listen 80;
>   server_namewww.example.com;
>   root /var/www/example/current/public;
>
>   location / {
>     passenger_enabled on;
>     ...
>   }
>
> }
>
> This works - all requests are processed correctly and the directives
> which addExpiresheaders work. Testing with ab from a remote host

sol

unread,
Apr 29, 2009, 7:06:51 AM4/29/09
to Phusion Passenger Discussions
I'm having a problem with location too, maybe this is related
somehow...
http://groups.google.com/group/phusion-passenger/browse_thread/thread/725dbe007d8c5c46

Hongli Lai

unread,
May 4, 2009, 7:38:00 PM5/4/09
to Phusion Passenger Discussions
I just tested this, and I confirm the symptoms that you're
experiencing.

On the surface this looks like an Nginx problem, but it's probably
worth investigating.

Hongli Lai

unread,
May 12, 2009, 12:08:03 PM5/12/09
to Phusion Passenger Discussions
On May 5, 1:38 am, Hongli Lai <hongli...@gmail.com> wrote:
> I just tested this, and I confirm the symptoms that you're
> experiencing.
>
> On the surface this looks like anNginxproblem, but it's probably
> worth investigating.

Actually, upon further investigation, I un-confirm this problem. The
variable performance that I experienced happened regardless of whether
there was a location block - it turned out to be caused by the
application itself.

I tested with a better application and I could not find any of the
symptoms that you described. There were no 403s either.

lardawge

unread,
May 12, 2009, 12:12:14 PM5/12/09
to Phusion Passenger Discussions
Can you post the server block you tested with? As stated in other
posts I have this problem with even an empty root location block...

Hongli Lai

unread,
May 12, 2009, 1:09:42 PM5/12/09
to phusion-...@googlegroups.com
On Tue, May 12, 2009 at 6:12 PM, lardawge <lard...@gmail.com> wrote:
>
> Can you post the server block you tested with? As stated in other
> posts I have this problem with even an empty root location block...

server {
listen 8000;
server_name eldorado.test;
root /Users/hongli/Sites/eldorado/public;
passenger_enabled on;
location / {
passenger_enabled on;
}
}

--
Phusion | The Computer Science Company

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl
Chamber of commerce no: 08173483 (The Netherlands)

lardawge

unread,
May 12, 2009, 1:36:57 PM5/12/09
to Phusion Passenger Discussions
Can you explain the need to have "passenger_enabled on;" in both the
server and the location block? I would say the way to duplicate it
would be to take the passenger_enabled on; out of the location block.
The bug would seem to be that it is necessary to have it in the
location block since the server block should pass it in (if I am
basing it on previous configs with thin or mongrel). That being said I
am not sure how passenger hooks into nginx since usually you have to
pass it off manually to other servers... Just trying to get some kind
of baseline for setting up advanced features for nginx with passenger.

Thanks for all your help on this!

On May 12, 1:09 pm, Hongli Lai <hon...@phusion.nl> wrote:
> On Tue, May 12, 2009 at 6:12 PM, lardawge <larda...@gmail.com> wrote:
>
> > Can you post the server block you tested with? As stated in other
> > posts I have this problem with even an empty root location block...
>
>     server {
>         listen 8000;
>         server_name eldorado.test;
>         root /Users/hongli/Sites/eldorado/public;
>         passenger_enabled on;
>         location / {
>             passenger_enabled on;
>         }
>     }
>
> --
> Phusion | The Computer Science Company
>
> Web:http://www.phusion.nl/
> E-mail: i...@phusion.nl

Hongli Lai

unread,
May 12, 2009, 1:56:33 PM5/12/09
to phusion-...@googlegroups.com
On Tue, May 12, 2009 at 7:36 PM, lardawge <lard...@gmail.com> wrote:
>
> Can you explain the need to have "passenger_enabled on;" in both the
> server and the location block?

It's not needed. If I remove the passenger_enabled directive in the
server blocks then it still behaves the same.

> basing it on previous configs with thin or mongrel). That being said I
> am not sure how passenger hooks into nginx since usually you have to
> pass it off manually to other servers...

As far as I know we hook into Nginx the same way every other
content-generating Nginx module does. We're not doing anything
special.

--
Phusion | The Computer Science Company

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl

lardawge

unread,
May 12, 2009, 2:06:43 PM5/12/09
to Phusion Passenger Discussions
>It's not needed. If I remove the passenger_enabled directive in the
>server blocks then it still behaves the same

If you re-read the various posts having problems with this including
the first one in this thread... The problem comes from putting the
passenger_enabled directive in the server block and not the location
block if there is a location block pointing to root. It is required in
the location block if the location block is a root location block or
you will get 403 errors... Maybe an addition to the docs?

Also what port does passenger listen on? I would like to use Nginx
upload_progress_module but do not know how to pass it off to passenger
when the upload is complete (requires a proxy_pass directive in the
root location block).

On May 12, 1:56 pm, Hongli Lai <hon...@phusion.nl> wrote:
> On Tue, May 12, 2009 at 7:36 PM, lardawge <larda...@gmail.com> wrote:
>
> > Can you explain the need to have "passenger_enabled on;" in both the
> > server and the location block?
>
> It's not needed. If I remove the passenger_enabled directive in the
> server blocks then it still behaves the same.
>
> > basing it on previous configs with thin or mongrel). That being said I
> > am not sure how passenger hooks into nginx since usually you have to
> > pass it off manually to other servers...
>
> As far as I know we hook into Nginx the same way every other
> content-generating Nginx module does. We're not doing anything
> special.
>
> --
> Phusion | The Computer Science Company
>
> Web:http://www.phusion.nl/
> E-mail: i...@phusion.nl

ijin

unread,
Jun 2, 2009, 8:20:33 AM6/2/09
to Phusion Passenger Discussions
I'm having a similar problem as well.

In my nginx.conf for my redmine app, I want to restrict access to /sys/
service.wsdl

The below location directive gives a 404 error.

root /usr/local/rails_apps/redmine/public;
passenger_enabled on;
location ^~ /sys/ {
allow 127.0.0.1;
allow 10.0.0.0/23;
deny all;
}

while, putting "passenger_enabled on;" inside the scope works.

root /usr/local/rails_apps/redmine/public;
passenger_enabled on;
location ^~ /sys/ {
passenger_enabled on;
allow 127.0.0.1;
allow 10.0.0.0/23;
deny all;
}

Strange.

sol

unread,
Jul 12, 2009, 4:08:57 AM7/12/09
to Phusion Passenger Discussions
is this problem with rewriting still existing in newer versions or has
it been fixed?

Hongli Lai

unread,
Jul 12, 2009, 5:40:11 AM7/12/09
to phusion-...@googlegroups.com
On Sun, Jul 12, 2009 at 10:08 AM, sol<ch.b...@gmail.com> wrote:
>
> is this problem with rewriting still existing in newer versions or has
> it been fixed?

It is an Nginx issue. Nothing we can do about it. You must re-specify
'passenger_enabled' in location blocks for the time being.

--
Phusion | The Computer Science Company

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl

Reply all
Reply to author
Forward
0 new messages