… | |
… | |
192 | $req->notes->set ("alias-forced-type" => "cgi-script"); # leave a note for mod_cgi, so it ignores missing ExecCGI |
192 | $req->notes->set ("alias-forced-type" => "cgi-script"); # leave a note for mod_cgi, so it ignores missing ExecCGI |
193 | _rpathname $path; |
193 | _rpathname $path; |
194 | } |
194 | } |
195 | |
195 | |
196 | # simplest reverse proxy, target is target url for this request |
196 | # simplest reverse proxy, target is target url for this request |
197 | sub rproxy($) { |
197 | sub rproxy($;$) { |
198 | my ($target) = @_; |
198 | my ($target, $preservehost) = @_; |
199 | |
199 | |
200 | $req->proxyreq (Apache2::Const::PROXYREQ_REVERSE); |
200 | $req->proxyreq (Apache2::Const::PROXYREQ_REVERSE); |
201 | $req->filename ("proxy:$target"); |
201 | $req->filename ("proxy:$target"); |
202 | $req->handler ("proxy-server"); |
202 | $req->handler ("proxy-server"); |
203 | $req->subprocess_env->set ("proxy-sendchunked", 1); |
203 | $req->subprocess_env->set ("proxy-sendchunked", 1); |
… | |
… | |
205 | #$env->set ("proxy-initial-not-pooled", 1); |
205 | #$env->set ("proxy-initial-not-pooled", 1); |
206 | |
206 | |
207 | # disable compression, see http://www.apachetutor.org/admin/reverseproxies |
207 | # disable compression, see http://www.apachetutor.org/admin/reverseproxies |
208 | # $req->headers_in->unset ("accept-encoding"); |
208 | # $req->headers_in->unset ("accept-encoding"); |
209 | # alternatively recompress, SetOutputFilter INFLATE;DEFLATE |
209 | # alternatively recompress, SetOutputFilter INFLATE;DEFLATE |
|
|
210 | |
|
|
211 | $req->add_config (["ProxyPreserveHost on"], ~0) |
|
|
212 | if $preservehost; |
210 | |
213 | |
211 | $req->headers_out->set ("x-forwarded-for", $req->connection->client_ip); |
214 | $req->headers_out->set ("x-forwarded-for", $req->connection->client_ip); |
212 | $req->headers_out->set ("x-forwarded-proto", "https"); # unable to find a way to access ap_http_scheme |
215 | $req->headers_out->set ("x-forwarded-proto", "https"); # unable to find a way to access ap_http_scheme |
213 | |
216 | |
214 | status Apache2::Const::OK; |
217 | status Apache2::Const::OK; |