Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

When on Nginx, ensure that SERVER_NAME equals HTTP_HOST without the p…

  • Loading branch information...
commit b4f28fe03d20f0fa569c07647a9f8ea46ce267e4 1 parent 14fb7bc
@FooBarWidget FooBarWidget authored
Showing with 18 additions and 1 deletion.
  1. +0 −1  ext/nginx/Configuration.c
  2. +18 −0 ext/nginx/ContentHandler.c
View
1  ext/nginx/Configuration.c
@@ -339,7 +339,6 @@ passenger_create_loc_conf(ngx_conf_t *cf)
DEFINE_VAR_TO_PASS("REMOTE_PORT", "$remote_port");
DEFINE_VAR_TO_PASS("SERVER_ADDR", "$server_addr");
DEFINE_VAR_TO_PASS("SERVER_PORT", "$server_port");
- DEFINE_VAR_TO_PASS("SERVER_NAME", "$server_name");
return conf;
}
View
18 ext/nginx/ContentHandler.c
@@ -321,12 +321,14 @@ create_request(ngx_http_request_t *r)
size_t len, size, key_len, val_len, content_length;
const u_char *app_type_string;
size_t app_type_string_len;
+ int server_name_len;
ngx_str_t escaped_uri;
ngx_str_t *union_station_filters = NULL;
u_char min_instances_string[12];
u_char framework_spawner_idle_time_string[12];
u_char app_spawner_idle_time_string[12];
u_char *end;
+ void *tmp;
ngx_uint_t i, n;
ngx_buf_t *b;
ngx_chain_t *cl, *body;
@@ -412,6 +414,16 @@ create_request(ngx_http_request_t *r)
len += 1 + r->args.len;
}
+ /* SERVER_NAME; must be equal to HTTP_HOST without the port part */
+ tmp = memchr(r->headers_in.host->value.data, ':', r->headers_in.host->value.len);
+ if (tmp == NULL) {
+ server_name_len = r->headers_in.host->value.len;
+ } else {
+ server_name_len = (int) ((const u_char *) tmp - r->headers_in.host->value.data);
+ }
+ len += sizeof("SERVER_NAME") + server_name_len + 1;
+ fprintf(stderr, "len = %d\n", server_name_len); fflush(stderr);
+
/* Various other HTTP headers. */
if (r->headers_in.content_type != NULL
&& r->headers_in.content_type->value.len > 0) {
@@ -637,6 +649,12 @@ create_request(ngx_http_request_t *r)
}
b->last = ngx_copy(b->last, "", 1);
+ /* SERVER_NAME */
+ b->last = ngx_copy(b->last, "SERVER_NAME", sizeof("SERVER_NAME"));
+ b->last = ngx_copy(b->last, r->headers_in.host->value.data,
+ server_name_len);
+ b->last = ngx_copy(b->last, "", 1);
+
/* Various other HTTP headers. */
if (r->headers_in.content_type != NULL
&& r->headers_in.content_type->value.len > 0) {
Please sign in to comment.
Something went wrong with that request. Please try again.