comparison src/http/modules/ngx_http_proxy_module.c @ 266:251bcd11a5b8 NGINX_0_5_3

nginx 0.5.3 *) Feature: the ngx_http_perl_module supports the $r->status, $r->log_error, and $r->sleep methods. *) Feature: the $r->variable method supports variables that do not exist in nginx configuration. *) Bugfix: the $r->has_request_body method did not work.
author Igor Sysoev <http://sysoev.ru>
date Wed, 13 Dec 2006 00:00:00 +0300
parents e0b1d0a6c629
children 6eb1e38f0f1f
comparison
equal deleted inserted replaced
265:3d4634b3b321 266:251bcd11a5b8
49 49
50 ngx_str_t body_source; 50 ngx_str_t body_source;
51 51
52 ngx_str_t method; 52 ngx_str_t method;
53 ngx_str_t host_header; 53 ngx_str_t host_header;
54 ngx_str_t port_text; 54 ngx_str_t port;
55 55
56 ngx_flag_t redirect; 56 ngx_flag_t redirect;
57 } ngx_http_proxy_loc_conf_t; 57 } ngx_http_proxy_loc_conf_t;
58 58
59 59
1230 { 1230 {
1231 ngx_http_proxy_loc_conf_t *plcf; 1231 ngx_http_proxy_loc_conf_t *plcf;
1232 1232
1233 plcf = ngx_http_get_module_loc_conf(r, ngx_http_proxy_module); 1233 plcf = ngx_http_get_module_loc_conf(r, ngx_http_proxy_module);
1234 1234
1235 v->len = plcf->port_text.len; 1235 v->len = plcf->port.len;
1236 v->valid = 1; 1236 v->valid = 1;
1237 v->no_cachable = 0; 1237 v->no_cachable = 0;
1238 v->not_found = 0; 1238 v->not_found = 0;
1239 v->data = plcf->port_text.data; 1239 v->data = plcf->port.data;
1240 1240
1241 return NGX_OK; 1241 return NGX_OK;
1242 } 1242 }
1243 1243
1244 1244
1815 1815
1816 if (conf->upstream.upstream == NULL) { 1816 if (conf->upstream.upstream == NULL) {
1817 conf->upstream.upstream = prev->upstream.upstream; 1817 conf->upstream.upstream = prev->upstream.upstream;
1818 1818
1819 conf->host_header = prev->host_header; 1819 conf->host_header = prev->host_header;
1820 conf->port_text = prev->port_text; 1820 conf->port = prev->port;
1821 conf->upstream.schema = prev->upstream.schema; 1821 conf->upstream.schema = prev->upstream.schema;
1822 } 1822 }
1823 1823
1824 1824
1825 if (conf->body_source.data == NULL) { 1825 if (conf->body_source.data == NULL) {
2091 static char * 2091 static char *
2092 ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 2092 ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
2093 { 2093 {
2094 ngx_http_proxy_loc_conf_t *plcf = conf; 2094 ngx_http_proxy_loc_conf_t *plcf = conf;
2095 2095
2096 u_char *p;
2096 size_t add; 2097 size_t add;
2097 u_short port; 2098 u_short port;
2098 ngx_str_t *value, *url; 2099 ngx_str_t *value, *url;
2099 ngx_url_t u; 2100 ngx_url_t u;
2100 ngx_http_core_loc_conf_t *clcf; 2101 ngx_http_core_loc_conf_t *clcf;
2156 2157
2157 ngx_memzero(&u, sizeof(ngx_url_t)); 2158 ngx_memzero(&u, sizeof(ngx_url_t));
2158 2159
2159 u.url.len = url->len - add; 2160 u.url.len = url->len - add;
2160 u.url.data = url->data + add; 2161 u.url.data = url->data + add;
2161 u.default_portn = port; 2162 u.default_port = port;
2162 u.upstream = 1; 2163 u.uri_part = 1;
2163 u.no_resolve = 1; 2164 u.no_resolve = 1;
2164 u.uri_part = 1;
2165 2165
2166 plcf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0); 2166 plcf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0);
2167 if (plcf->upstream.upstream == NULL) { 2167 if (plcf->upstream.upstream == NULL) {
2168 return NGX_CONF_ERROR; 2168 return NGX_CONF_ERROR;
2169 } 2169 }
2170 2170
2171 plcf->host_header = u.host_header; 2171 if (!u.unix_socket) {
2172 plcf->port_text = u.port; 2172 if (u.no_port || u.port == port) {
2173 plcf->host_header = u.host;
2174
2175 if (port == 80) {
2176 plcf->port.len = sizeof("80") - 1;
2177 plcf->port.data = (u_char *) "80";
2178 } else {
2179 plcf->port.len = sizeof("443") - 1;
2180 plcf->port.data = (u_char *) "443";
2181 }
2182
2183 } else {
2184 p = ngx_palloc(cf->pool, u.host.len + sizeof(":65536") - 1);
2185 if (p == NULL) {
2186 return NGX_CONF_ERROR;
2187 }
2188
2189 plcf->host_header.len = ngx_sprintf(p, "%V:%d", &u.host, u.port)
2190 - p;
2191 plcf->host_header.data = p;
2192
2193 plcf->port.len = plcf->host_header.len - u.host.len - 1;
2194 plcf->port.data = p + u.host.len + 1;
2195 }
2196
2197
2198 } else {
2199 plcf->host_header.len = sizeof("localhost") - 1;
2200 plcf->host_header.data = (u_char *) "localhost";
2201 plcf->port.len = 0;
2202 plcf->port.data = (u_char *) "";
2203 }
2204
2173 plcf->upstream.uri = u.uri; 2205 plcf->upstream.uri = u.uri;
2174 2206
2175 plcf->upstream.schema.len = add; 2207 plcf->upstream.schema.len = add;
2176 plcf->upstream.schema.data = url->data; 2208 plcf->upstream.schema.data = url->data;
2177 2209