passenger 5.0.10 → 5.0.11
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of passenger might be problematic. Click here for more details.
- checksums.yaml +8 -8
- checksums.yaml.gz.asc +7 -7
- data.tar.gz.asc +7 -7
- data/CHANGELOG +18 -0
- data/CONTRIBUTING.md +3 -3
- data/bin/passenger-status +12 -4
- data/build/agents.rb +45 -45
- data/build/apache2.rb +1 -1
- data/build/basics.rb +1 -1
- data/build/cxx_tests.rb +12 -12
- data/doc/CloudLicensingConfiguration.html +10 -10
- data/doc/CloudLicensingConfiguration.txt.md +10 -10
- data/doc/DebuggingAndStressTesting.md +3 -3
- data/doc/Design and Architecture.html +30 -30
- data/doc/Design and Architecture.txt +28 -28
- data/doc/ServerOptimizationGuide.html +3 -3
- data/doc/ServerOptimizationGuide.txt.md +3 -3
- data/doc/Users guide Apache.html +24 -12
- data/doc/Users guide Apache.txt +2 -2
- data/doc/Users guide Nginx.html +24 -12
- data/doc/Users guide Nginx.txt +2 -2
- data/doc/Users guide Standalone.html +18 -6
- data/doc/images/passenger_architecture.png +0 -0
- data/doc/images/passenger_architecture.svg +10 -9
- data/doc/images/{helper_agent_core_architecture.png → passenger_core_architecture.png} +0 -0
- data/doc/users_guide_snippets/environment_variables.txt +1 -1
- data/doc/users_guide_snippets/installation/verify_running_epilogue.txt +1 -1
- data/doc/users_guide_snippets/support_information.txt +1 -1
- data/doc/users_guide_snippets/tips.txt +2 -2
- data/doc/users_guide_snippets/under_the_hood/relationship_with_ruby.txt +1 -1
- data/ext/apache2/Bucket.h +5 -5
- data/ext/apache2/Configuration.cpp +1 -1
- data/ext/apache2/Configuration.hpp +2 -3
- data/ext/apache2/ConfigurationFields.hpp +3 -0
- data/ext/apache2/ConfigurationFields.hpp.erb +3 -0
- data/ext/apache2/Hooks.cpp +42 -34
- data/ext/common/Account.h +3 -3
- data/ext/common/AgentsStarter.cpp +7 -7
- data/ext/common/AgentsStarter.h +20 -20
- data/ext/common/ApplicationPool2/Options.h +12 -12
- data/ext/common/Constants.h +10 -8
- data/ext/common/Logging.cpp +22 -1
- data/ext/common/Logging.h +19 -2
- data/ext/common/ServerKit/AcceptLoadBalancer.h +3 -3
- data/ext/common/ServerKit/Server.h +24 -0
- data/ext/common/UnionStation/Connection.h +1 -1
- data/ext/common/UnionStation/Core.h +21 -21
- data/ext/common/UnionStation/Transaction.h +3 -3
- data/ext/common/Utils.cpp +2 -2
- data/ext/common/Utils/IOUtils.cpp +5 -1
- data/ext/common/{agents → agent}/ApiServerUtils.h +3 -3
- data/ext/common/{agents → agent}/Base.cpp +2 -2
- data/ext/common/{agents → agent}/Base.h +0 -0
- data/ext/common/{agents/HelperAgent → agent/Core}/ApiServer.h +33 -9
- data/ext/common/{agents/HelperAgent → agent/Core}/Main.cpp +60 -59
- data/ext/common/{agents/HelperAgent → agent/Core}/OptionParser.h +32 -25
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler.h +17 -17
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/AppResponse.h +0 -0
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/BufferBody.cpp +0 -0
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/CheckoutSession.cpp +0 -0
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/Client.h +2 -2
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/ForwardResponse.cpp +0 -0
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/Hooks.cpp +0 -0
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/InitRequest.cpp +4 -3
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/Request.h +1 -1
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/SendRequest.cpp +0 -0
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/TurboCaching.h +1 -1
- data/ext/common/{agents/HelperAgent → agent/Core}/RequestHandler/Utils.cpp +0 -0
- data/ext/common/{agents/HelperAgent → agent/Core}/ResponseCache.h +0 -0
- data/ext/common/{agents → agent}/Main.cpp +9 -9
- data/ext/common/{agents → agent}/SpawnPreparer/Main.cpp +0 -0
- data/ext/common/{agents/HelperAgent/SystemMetricsTool.cpp → agent/SystemMetrics/Main.cpp} +0 -0
- data/ext/common/{agents → agent}/TempDirToucher/Main.cpp +0 -0
- data/ext/common/{agents/LoggingAgent → agent/UstRouter}/ApiServer.h +7 -7
- data/ext/common/{agents/LoggingAgent → agent/UstRouter}/DataStoreId.h +0 -0
- data/ext/common/{agents/LoggingAgent → agent/UstRouter}/FilterSupport.cpp +0 -0
- data/ext/common/{agents/LoggingAgent → agent/UstRouter}/FilterSupport.h +0 -0
- data/ext/common/{agents/LoggingAgent → agent/UstRouter}/LoggingServer.h +4 -4
- data/ext/common/{agents/LoggingAgent → agent/UstRouter}/Main.cpp +45 -45
- data/ext/common/{agents/LoggingAgent → agent/UstRouter}/OptionParser.h +20 -20
- data/ext/common/{agents/LoggingAgent → agent/UstRouter}/RemoteSender.h +0 -0
- data/ext/common/{agents → agent}/Watchdog/AgentWatcher.cpp +0 -0
- data/ext/common/{agents → agent}/Watchdog/ApiServer.h +1 -1
- data/ext/common/{agents/Watchdog/HelperAgentWatcher.cpp → agent/Watchdog/CoreWatcher.cpp} +14 -10
- data/ext/common/{agents → agent}/Watchdog/InstanceDirToucher.cpp +0 -0
- data/ext/common/{agents → agent}/Watchdog/Main.cpp +131 -75
- data/ext/common/{agents/Watchdog/LoggingAgentWatcher.cpp → agent/Watchdog/UstRouterWatcher.cpp} +13 -9
- data/ext/nginx/CacheLocationConfig.c +11 -6
- data/ext/nginx/CacheLocationConfig.c.erb +11 -6
- data/ext/nginx/Configuration.c +22 -7
- data/ext/nginx/Configuration.h +1 -19
- data/ext/nginx/ConfigurationFields.h +19 -0
- data/ext/nginx/ConfigurationFields.h.erb +19 -0
- data/ext/nginx/ContentHandler.c +33 -33
- data/ext/nginx/CreateLocationConfig.c +3 -1
- data/ext/nginx/CreateLocationConfig.c.erb +3 -1
- data/ext/nginx/MergeLocationConfig.c +8 -4
- data/ext/nginx/MergeLocationConfig.c.erb +7 -3
- data/ext/nginx/ngx_http_passenger_module.c +33 -42
- data/helper-scripts/backtrace-sanitizer.rb +2 -2
- data/lib/phusion_passenger.rb +1 -1
- data/lib/phusion_passenger/admin_tools/instance.rb +2 -2
- data/lib/phusion_passenger/admin_tools/instance_registry.rb +7 -3
- data/lib/phusion_passenger/common_library.rb +8 -8
- data/lib/phusion_passenger/config/about_command.rb +1 -1
- data/lib/phusion_passenger/config/api_call_command.rb +3 -3
- data/lib/phusion_passenger/config/installation_utils.rb +34 -21
- data/lib/phusion_passenger/config/reopen_logs_command.rb +2 -2
- data/lib/phusion_passenger/config/restart_app_command.rb +18 -4
- data/lib/phusion_passenger/constants.rb +7 -5
- data/lib/phusion_passenger/loader_shared_helpers.rb +2 -6
- data/lib/phusion_passenger/message_client.rb +8 -8
- data/lib/phusion_passenger/platform_info/ruby.rb +1 -2
- data/lib/phusion_passenger/preloader_shared_helpers.rb +1 -1
- data/lib/phusion_passenger/request_handler.rb +3 -2
- data/lib/phusion_passenger/request_handler/thread_handler.rb +4 -4
- data/lib/phusion_passenger/standalone/start_command.rb +13 -3
- data/lib/phusion_passenger/standalone/start_command/builtin_engine.rb +2 -1
- data/lib/phusion_passenger/union_station/core.rb +18 -18
- data/lib/phusion_passenger/union_station/transaction.rb +5 -5
- data/resources/oss-binaries.phusionpassenger.com.crt +0 -84
- data/resources/templates/standalone/config.erb +1 -0
- metadata +40 -40
- metadata.gz.asc +7 -7
data/ext/common/{agents/Watchdog/LoggingAgentWatcher.cpp → agent/Watchdog/UstRouterWatcher.cpp}
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
* Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
-
* Copyright (c) 2010-
|
3
|
+
* Copyright (c) 2010-2015 Phusion
|
4
4
|
*
|
5
5
|
* "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
6
6
|
*
|
@@ -23,13 +23,13 @@
|
|
23
23
|
* THE SOFTWARE.
|
24
24
|
*/
|
25
25
|
|
26
|
-
class
|
26
|
+
class UstRouterWatcher: public AgentWatcher {
|
27
27
|
protected:
|
28
28
|
string agentFilename;
|
29
29
|
string socketAddress;
|
30
30
|
|
31
31
|
virtual const char *name() const {
|
32
|
-
return
|
32
|
+
return SHORT_PROGRAM_NAME " UstRouter";
|
33
33
|
}
|
34
34
|
|
35
35
|
virtual string getExeFilename() const {
|
@@ -37,15 +37,15 @@ protected:
|
|
37
37
|
}
|
38
38
|
|
39
39
|
virtual void execProgram() const {
|
40
|
-
execl(agentFilename.c_str(), AGENT_EXE, "
|
40
|
+
execl(agentFilename.c_str(), AGENT_EXE, "ust-router",
|
41
41
|
// Some extra space to allow the child process to change its process title.
|
42
42
|
" ", (char *) 0);
|
43
43
|
}
|
44
44
|
|
45
45
|
virtual void sendStartupArguments(pid_t pid, FileDescriptor &fd) {
|
46
46
|
VariantMap options = *agentsOptions;
|
47
|
-
options.erase("
|
48
|
-
options.erase("
|
47
|
+
options.erase("core_password");
|
48
|
+
options.erase("core_authorizations");
|
49
49
|
options.writeToFd(fd);
|
50
50
|
}
|
51
51
|
|
@@ -54,7 +54,7 @@ protected:
|
|
54
54
|
}
|
55
55
|
|
56
56
|
public:
|
57
|
-
|
57
|
+
UstRouterWatcher(const WorkingObjectsPtr &wo)
|
58
58
|
: AgentWatcher(wo)
|
59
59
|
{
|
60
60
|
agentFilename = wo->resourceLocator->findSupportBinary(AGENT_EXE);
|
@@ -62,7 +62,11 @@ public:
|
|
62
62
|
|
63
63
|
virtual void reportAgentsInformation(VariantMap &report) {
|
64
64
|
const VariantMap &options = *agentsOptions;
|
65
|
-
report.set("
|
66
|
-
report.set("
|
65
|
+
report.set("ust_router_address", options.get("ust_router_address"));
|
66
|
+
report.set("ust_router_password", options.get("ust_router_password"));
|
67
|
+
|
68
|
+
// For backward compatibilty:
|
69
|
+
report.set("logging_agent_address", options.get("ust_router_address"));
|
70
|
+
report.set("logging_agent_password", options.get("ust_router_password"));
|
67
71
|
}
|
68
72
|
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
* Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
-
* Copyright (c) 2010-
|
3
|
+
* Copyright (c) 2010-2015 Phusion
|
4
4
|
*
|
5
5
|
* "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
6
6
|
*
|
@@ -38,8 +38,10 @@
|
|
38
38
|
|
39
39
|
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
/* 0: NGX_ERROR, 1: OK */
|
42
|
+
int generated_cache_location_part(ngx_conf_t *cf, passenger_loc_conf_t *conf) {
|
43
|
+
size_t len = 0;
|
44
|
+
u_char int_buf[32], *end, *buf, *pos;
|
43
45
|
|
44
46
|
/* Calculate lengths */
|
45
47
|
|
@@ -304,7 +306,7 @@ u_char int_buf[32], *end, *buf, *pos;
|
|
304
306
|
/* Create string */
|
305
307
|
buf = pos = ngx_pnalloc(cf->pool, len);
|
306
308
|
if (buf == NULL) {
|
307
|
-
return
|
309
|
+
return 0;
|
308
310
|
}
|
309
311
|
|
310
312
|
|
@@ -664,5 +666,8 @@ if (buf == NULL) {
|
|
664
666
|
|
665
667
|
|
666
668
|
|
667
|
-
conf->options_cache.data = buf;
|
668
|
-
conf->options_cache.len = pos - buf;
|
669
|
+
conf->options_cache.data = buf;
|
670
|
+
conf->options_cache.len = pos - buf;
|
671
|
+
|
672
|
+
return 1;
|
673
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
* Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
-
* Copyright (c) 2010-
|
3
|
+
* Copyright (c) 2010-2015 Phusion
|
4
4
|
*
|
5
5
|
* "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
6
6
|
*
|
@@ -61,8 +61,10 @@ def header_name_for(option)
|
|
61
61
|
end
|
62
62
|
%>
|
63
63
|
|
64
|
-
|
65
|
-
|
64
|
+
/* 0: NGX_ERROR, 1: OK */
|
65
|
+
int generated_cache_location_part(ngx_conf_t *cf, passenger_loc_conf_t *conf) {
|
66
|
+
size_t len = 0;
|
67
|
+
u_char int_buf[32], *end, *buf, *pos;
|
66
68
|
|
67
69
|
/* Calculate lengths */
|
68
70
|
<% for option in filter_eligible_options(LOCATION_CONFIGURATION_OPTIONS) %>
|
@@ -107,7 +109,7 @@ u_char int_buf[32], *end, *buf, *pos;
|
|
107
109
|
/* Create string */
|
108
110
|
buf = pos = ngx_pnalloc(cf->pool, len);
|
109
111
|
if (buf == NULL) {
|
110
|
-
return
|
112
|
+
return 0;
|
111
113
|
}
|
112
114
|
|
113
115
|
<% for option in filter_eligible_options(LOCATION_CONFIGURATION_OPTIONS) %>
|
@@ -149,5 +151,8 @@ if (buf == NULL) {
|
|
149
151
|
<% end %>
|
150
152
|
<% end %>
|
151
153
|
|
152
|
-
conf->options_cache.data = buf;
|
153
|
-
conf->options_cache.len = pos - buf;
|
154
|
+
conf->options_cache.data = buf;
|
155
|
+
conf->options_cache.len = pos - buf;
|
156
|
+
|
157
|
+
return 1;
|
158
|
+
}
|
data/ext/nginx/Configuration.c
CHANGED
@@ -38,7 +38,7 @@
|
|
38
38
|
#include "Configuration.h"
|
39
39
|
#include "ContentHandler.h"
|
40
40
|
#include "common/Constants.h"
|
41
|
-
#include "common/
|
41
|
+
#include "common/agent/UstRouter/FilterSupport.h"
|
42
42
|
#include "common/Utils/modp_b64.h"
|
43
43
|
|
44
44
|
|
@@ -248,6 +248,8 @@ passenger_init_main_conf(ngx_conf_t *cf, void *conf_pointer)
|
|
248
248
|
return NGX_CONF_OK;
|
249
249
|
}
|
250
250
|
|
251
|
+
#include "CreateLocationConfig.c"
|
252
|
+
|
251
253
|
void *
|
252
254
|
passenger_create_loc_conf(ngx_conf_t *cf)
|
253
255
|
{
|
@@ -273,7 +275,7 @@ passenger_create_loc_conf(ngx_conf_t *cf)
|
|
273
275
|
* conf->upstream_config.store_values = NULL;
|
274
276
|
*/
|
275
277
|
|
276
|
-
|
278
|
+
generated_set_conf_part(conf);
|
277
279
|
|
278
280
|
/******************************/
|
279
281
|
/******************************/
|
@@ -349,6 +351,8 @@ passenger_create_loc_conf(ngx_conf_t *cf)
|
|
349
351
|
return conf;
|
350
352
|
}
|
351
353
|
|
354
|
+
#include "CacheLocationConfig.c"
|
355
|
+
|
352
356
|
static ngx_int_t
|
353
357
|
cache_loc_conf_options(ngx_conf_t *cf, passenger_loc_conf_t *conf)
|
354
358
|
{
|
@@ -357,9 +361,15 @@ cache_loc_conf_options(ngx_conf_t *cf, passenger_loc_conf_t *conf)
|
|
357
361
|
size_t unencoded_len;
|
358
362
|
u_char *unencoded_buf;
|
359
363
|
|
360
|
-
|
364
|
+
if (generated_cache_location_part(cf, conf) == 0) {
|
365
|
+
return NGX_ERROR;
|
366
|
+
}
|
361
367
|
|
362
368
|
if (conf->env_vars != NULL) {
|
369
|
+
size_t len = 0;
|
370
|
+
u_char *buf;
|
371
|
+
u_char *pos;
|
372
|
+
|
363
373
|
/* Cache env vars data as base64-serialized string.
|
364
374
|
* First, calculate the length of the unencoded data.
|
365
375
|
*/
|
@@ -418,6 +428,8 @@ cache_loc_conf_options(ngx_conf_t *cf, passenger_loc_conf_t *conf)
|
|
418
428
|
return NGX_OK;
|
419
429
|
}
|
420
430
|
|
431
|
+
#include "MergeLocationConfig.c"
|
432
|
+
|
421
433
|
char *
|
422
434
|
passenger_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
423
435
|
{
|
@@ -430,7 +442,10 @@ passenger_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
|
430
442
|
|
431
443
|
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
|
432
444
|
|
433
|
-
|
445
|
+
if (generated_merge_part(conf, prev, cf) == 0) {
|
446
|
+
return NGX_CONF_ERROR;
|
447
|
+
}
|
448
|
+
|
434
449
|
if (prev->options_cache.data == NULL) {
|
435
450
|
if (cache_loc_conf_options(cf, prev) != NGX_OK) {
|
436
451
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
@@ -1106,9 +1121,9 @@ passenger_enabled(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
1106
1121
|
passenger_conf->enabled = 1;
|
1107
1122
|
|
1108
1123
|
/* Register a placeholder value as upstream address. The real upstream
|
1109
|
-
* address (the
|
1110
|
-
* requests, because we can't start the
|
1111
|
-
* loading is done.
|
1124
|
+
* address (the Passenger core socket filename) will be set while processing
|
1125
|
+
* requests, because we can't start the watchdog (and thus the Passenger core)
|
1126
|
+
* until config loading is done.
|
1112
1127
|
*/
|
1113
1128
|
ngx_memzero(&upstream_url, sizeof(ngx_url_t));
|
1114
1129
|
upstream_url.url = pp_placeholder_upstream_address;
|
data/ext/nginx/Configuration.h
CHANGED
@@ -31,25 +31,7 @@
|
|
31
31
|
#include <ngx_config.h>
|
32
32
|
#include <ngx_http.h>
|
33
33
|
|
34
|
-
|
35
|
-
ngx_http_upstream_conf_t upstream_config;
|
36
|
-
ngx_array_t *flushes;
|
37
|
-
ngx_array_t *headers_set_len;
|
38
|
-
ngx_array_t *headers_set;
|
39
|
-
ngx_hash_t headers_set_hash;
|
40
|
-
|
41
|
-
/** Raw HTTP header data for this location are cached here. */
|
42
|
-
ngx_str_t options_cache;
|
43
|
-
ngx_str_t env_vars_cache;
|
44
|
-
|
45
|
-
#include "ConfigurationFields.h"
|
46
|
-
|
47
|
-
#if (NGX_HTTP_CACHE)
|
48
|
-
ngx_http_complex_value_t cache_key;
|
49
|
-
#endif
|
50
|
-
|
51
|
-
/************************************/
|
52
|
-
} passenger_loc_conf_t;
|
34
|
+
#include "ConfigurationFields.h"
|
53
35
|
|
54
36
|
typedef struct {
|
55
37
|
ngx_str_t root_dir;
|
@@ -35,6 +35,17 @@
|
|
35
35
|
* rm -f ext/nginx/ConfigurationFields.h
|
36
36
|
* rake ext/nginx/ConfigurationFields.h
|
37
37
|
*/
|
38
|
+
|
39
|
+
typedef struct {
|
40
|
+
ngx_http_upstream_conf_t upstream_config;
|
41
|
+
ngx_array_t *flushes;
|
42
|
+
ngx_array_t *headers_set_len;
|
43
|
+
ngx_array_t *headers_set;
|
44
|
+
ngx_hash_t headers_set_hash;
|
45
|
+
|
46
|
+
/** Raw HTTP header data for this location are cached here. */
|
47
|
+
ngx_str_t options_cache;
|
48
|
+
ngx_str_t env_vars_cache;
|
38
49
|
|
39
50
|
|
40
51
|
|
@@ -113,3 +124,11 @@
|
|
113
124
|
|
114
125
|
ngx_str_t vary_turbocache_by_cookie;
|
115
126
|
|
127
|
+
|
128
|
+
|
129
|
+
#if (NGX_HTTP_CACHE)
|
130
|
+
ngx_http_complex_value_t cache_key;
|
131
|
+
#endif
|
132
|
+
|
133
|
+
/************************************/
|
134
|
+
} passenger_loc_conf_t;
|
@@ -35,6 +35,17 @@
|
|
35
35
|
* rm -f ext/nginx/ConfigurationFields.h
|
36
36
|
* rake ext/nginx/ConfigurationFields.h
|
37
37
|
*/
|
38
|
+
|
39
|
+
typedef struct {
|
40
|
+
ngx_http_upstream_conf_t upstream_config;
|
41
|
+
ngx_array_t *flushes;
|
42
|
+
ngx_array_t *headers_set_len;
|
43
|
+
ngx_array_t *headers_set;
|
44
|
+
ngx_hash_t headers_set_hash;
|
45
|
+
|
46
|
+
/** Raw HTTP header data for this location are cached here. */
|
47
|
+
ngx_str_t options_cache;
|
48
|
+
ngx_str_t env_vars_cache;
|
38
49
|
|
39
50
|
<%
|
40
51
|
require 'phusion_passenger/nginx/config_options'
|
@@ -90,3 +101,11 @@ end
|
|
90
101
|
<% for definition in definitions %>
|
91
102
|
<%= definition[0] %>;
|
92
103
|
<% end %>
|
104
|
+
|
105
|
+
|
106
|
+
#if (NGX_HTTP_CACHE)
|
107
|
+
ngx_http_complex_value_t cache_key;
|
108
|
+
#endif
|
109
|
+
|
110
|
+
/************************************/
|
111
|
+
} passenger_loc_conf_t;
|
data/ext/nginx/ContentHandler.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* Copyright (C) Igor Sysoev
|
3
3
|
* Copyright (C) 2007 Manlio Perillo (manlio.perillo@gmail.com)
|
4
|
-
* Copyright (C) 2010-
|
4
|
+
* Copyright (C) 2010-2015 Phusion
|
5
5
|
*
|
6
6
|
* Redistribution and use in source and binary forms, with or without
|
7
7
|
* modification, are permitted provided that the following conditions
|
@@ -207,35 +207,35 @@ static void
|
|
207
207
|
set_upstream_server_address(ngx_http_upstream_t *upstream, ngx_http_upstream_conf_t *upstream_config) {
|
208
208
|
ngx_http_upstream_server_t *servers = upstream_config->upstream->servers->elts;
|
209
209
|
ngx_addr_t *address = &servers[0].addrs[0];
|
210
|
-
const char *
|
211
|
-
unsigned int
|
210
|
+
const char *core_address;
|
211
|
+
unsigned int core_address_len;
|
212
212
|
struct sockaddr_un *sockaddr;
|
213
213
|
|
214
214
|
/* The Nginx API makes it extremely difficult to register an upstream server
|
215
215
|
* address outside of the configuration loading phase. However we don't know
|
216
|
-
* the
|
216
|
+
* the Passenger core's request socket filename until we're done with loading
|
217
217
|
* the configuration. So during configuration loading we register a placeholder
|
218
218
|
* address for the upstream configuration, and while processing requests
|
219
|
-
* we substitute the placeholder filename with the real
|
219
|
+
* we substitute the placeholder filename with the real Passenger core request
|
220
220
|
* socket filename.
|
221
221
|
*/
|
222
222
|
if (address->name.data == pp_placeholder_upstream_address.data) {
|
223
223
|
sockaddr = (struct sockaddr_un *) address->sockaddr;
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
address->name.data = (u_char *)
|
231
|
-
address->name.len =
|
232
|
-
strncpy(sockaddr->sun_path,
|
224
|
+
core_address =
|
225
|
+
pp_agents_starter_get_core_address(pp_agents_starter,
|
226
|
+
&core_address_len);
|
227
|
+
core_address += sizeof("unix:") - 1;
|
228
|
+
core_address_len -= sizeof("unix:") - 1;
|
229
|
+
|
230
|
+
address->name.data = (u_char *) core_address;
|
231
|
+
address->name.len = core_address_len;
|
232
|
+
strncpy(sockaddr->sun_path, core_address, sizeof(sockaddr->sun_path));
|
233
233
|
sockaddr->sun_path[sizeof(sockaddr->sun_path) - 1] = '\0';
|
234
234
|
}
|
235
235
|
}
|
236
236
|
|
237
237
|
/**
|
238
|
-
* If the
|
238
|
+
* If the Passenger core socket cannot be connected to then we want Nginx to print
|
239
239
|
* the proper socket filename in the error message. The socket filename is stored
|
240
240
|
* in one of the upstream peer data structures. This name is initialized during
|
241
241
|
* the first ngx_http_read_client_request_body() call so there's no way to fix the
|
@@ -247,8 +247,8 @@ fix_peer_address(ngx_http_request_t *r) {
|
|
247
247
|
ngx_http_upstream_rr_peers_t *peers;
|
248
248
|
ngx_http_upstream_rr_peer_t *peer;
|
249
249
|
unsigned int peer_index;
|
250
|
-
const char *
|
251
|
-
unsigned int
|
250
|
+
const char *core_address;
|
251
|
+
unsigned int core_address_len;
|
252
252
|
|
253
253
|
if (r->upstream->peer.get != ngx_http_upstream_get_round_robin_peer) {
|
254
254
|
/* This function only supports the round-robin upstream method. */
|
@@ -257,24 +257,24 @@ fix_peer_address(ngx_http_request_t *r) {
|
|
257
257
|
|
258
258
|
rrp = r->upstream->peer.data;
|
259
259
|
peers = rrp->peers;
|
260
|
-
|
261
|
-
|
262
|
-
&
|
260
|
+
core_address =
|
261
|
+
pp_agents_starter_get_core_address(pp_agents_starter,
|
262
|
+
&core_address_len);
|
263
263
|
|
264
264
|
while (peers != NULL) {
|
265
265
|
if (peers->name) {
|
266
|
-
if (peers->name->data == (u_char *)
|
266
|
+
if (peers->name->data == (u_char *) core_address) {
|
267
267
|
/* Peer names already fixed. */
|
268
268
|
return;
|
269
269
|
}
|
270
|
-
peers->name->data = (u_char *)
|
271
|
-
peers->name->len =
|
270
|
+
peers->name->data = (u_char *) core_address;
|
271
|
+
peers->name->len = core_address_len;
|
272
272
|
}
|
273
273
|
peer_index = 0;
|
274
274
|
while (1) {
|
275
275
|
peer = &peers->peer[peer_index];
|
276
|
-
peer->name.data = (u_char *)
|
277
|
-
peer->name.len =
|
276
|
+
peer->name.data = (u_char *) core_address;
|
277
|
+
peer->name.len = core_address_len;
|
278
278
|
if (peer->down) {
|
279
279
|
peer_index++;
|
280
280
|
} else {
|
@@ -312,7 +312,7 @@ create_key(ngx_http_request_t *r)
|
|
312
312
|
|
313
313
|
/**
|
314
314
|
* Checks whether the given header is "Transfer-Encoding".
|
315
|
-
* We do not pass Transfer-Encoding headers to the
|
315
|
+
* We do not pass Transfer-Encoding headers to the Passenger core because
|
316
316
|
* Nginx always buffers the request body and always sets Content-Length
|
317
317
|
* in the request headers.
|
318
318
|
*/
|
@@ -342,7 +342,7 @@ typedef struct {
|
|
342
342
|
ngx_str_t app_type;
|
343
343
|
ngx_str_t escaped_uri;
|
344
344
|
ngx_str_t content_length;
|
345
|
-
ngx_str_t
|
345
|
+
ngx_str_t core_password;
|
346
346
|
ngx_str_t remote_port;
|
347
347
|
} buffer_construction_state;
|
348
348
|
|
@@ -448,9 +448,9 @@ prepare_request_buffer_construction(ngx_http_request_t *r, passenger_context_t *
|
|
448
448
|
- state->content_length.data;
|
449
449
|
}
|
450
450
|
|
451
|
-
state->
|
451
|
+
state->core_password.data = (u_char *) pp_agents_starter_get_core_password(
|
452
452
|
pp_agents_starter, &len);
|
453
|
-
state->
|
453
|
+
state->core_password.len = len;
|
454
454
|
|
455
455
|
switch (r->connection->sockaddr->sa_family) {
|
456
456
|
#if (NGX_HAVE_INET6)
|
@@ -628,11 +628,11 @@ construct_request_buffer(ngx_http_request_t *r, passenger_loc_conf_t *slcf,
|
|
628
628
|
|
629
629
|
if (b != NULL) {
|
630
630
|
b->last = ngx_copy(b->last, "!~: ", sizeof("!~: ") - 1);
|
631
|
-
b->last = ngx_copy(b->last, state->
|
632
|
-
state->
|
631
|
+
b->last = ngx_copy(b->last, state->core_password.data,
|
632
|
+
state->core_password.len);
|
633
633
|
b->last = ngx_copy(b->last, "\r\n", sizeof("\r\n") - 1);
|
634
634
|
}
|
635
|
-
total_size += (sizeof("!~: \r\n") - 1) + state->
|
635
|
+
total_size += (sizeof("!~: \r\n") - 1) + state->core_password.len;
|
636
636
|
|
637
637
|
PUSH_STATIC_STR("!~DOCUMENT_ROOT: ");
|
638
638
|
if (b != NULL) {
|
@@ -1450,7 +1450,7 @@ passenger_content_handler(ngx_http_request_t *r)
|
|
1450
1450
|
}
|
1451
1451
|
|
1452
1452
|
|
1453
|
-
/* Setup upstream stuff and prepare sending the request to the
|
1453
|
+
/* Setup upstream stuff and prepare sending the request to the Passenger core. */
|
1454
1454
|
|
1455
1455
|
if (ngx_http_upstream_create(r) != NGX_OK) {
|
1456
1456
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|