From 41a6576f1bcb45e3f3a5d848dd259544cb27b960 Mon Sep 17 00:00:00 2001 From: "Hongli Lai (Phusion)" Date: Mon, 2 Mar 2015 17:27:27 +0100 Subject: [PATCH] Nginx: fixes cases in which Passenger overrides the Nginx handler function even when it shouldn't For example when Passenger is disabled. Closes GH-1393. --- CHANGELOG | 1 + doc/Users guide Nginx.txt | 12 ++++++++++++ ext/nginx/Configuration.c | 5 ++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index d91037aed3..0e38acdacd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ Release 5.0.1 * The `passenger-config restart-app` command is now more user friendly. When run in a terminal, it will show an interactive menu, allowing you to select the app to restart. Closes GH-1387. * Fixes a crash bug in the handling of sticky session cookies. + * [Nginx] Fixes cases in which Passenger overrides the Nginx handler function even when it shouldn't, for example when Passenger is disabled. Closes GH-1393. * [Enterprise] The `sticky_sessions` and `envvars` options in Passengerfile.json is now also supported in mass deployment mode. diff --git a/doc/Users guide Nginx.txt b/doc/Users guide Nginx.txt index 9b8aa71988..8dedbe74c1 100644 --- a/doc/Users guide Nginx.txt +++ b/doc/Users guide Nginx.txt @@ -430,6 +430,18 @@ Please see <> and <> for examples. +------------------------------ +server { + listen 80; + server_name www.example.com; + root /webapps/example/public; + + # You must explicitly set 'passenger_enabled on', otherwise + # Phusion Passenger won't serve this app. + passenger_enabled on; +} +------------------------------ + [[PassengerBaseURI]] ==== passenger_base_uri Used to specify that the given URI is an distinct application that should diff --git a/ext/nginx/Configuration.c b/ext/nginx/Configuration.c index a20396bddb..4a2708bb6b 100644 --- a/ext/nginx/Configuration.c +++ b/ext/nginx/Configuration.c @@ -745,7 +745,10 @@ passenger_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) conf->upstream_config.upstream = prev->upstream_config.upstream; } - if (conf->enabled) { + if (conf->enabled == 1 /* and not NGX_CONF_UNSET */ + && passenger_main_conf.root_dir.len != 0 + && clcf->handler == NULL /* no handler set by other modules */) + { clcf->handler = passenger_content_handler; }