diff options
author | Jan Lehnardt <jan@apache.org> | 2009-08-18 17:09:42 +0000 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2009-08-18 17:09:42 +0000 |
commit | 0a902eb4ad64ee86f8af9915efb26a46bbb84d50 (patch) | |
tree | c16733966d49a5137f5a04ab03bebb4431ad1be0 /src | |
parent | 3d96395f24baf66956de819a83bd3615ba45d721 (diff) |
allow configurable X-Forwarded-Host header handling for work behind reverse proxies, patch by Benoit Chesneau, closes COUCHDB-466
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@805500 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/couchdb/couch_httpd.erl | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl index 2dc53b80..61bdc177 100644 --- a/src/couchdb/couch_httpd.erl +++ b/src/couchdb/couch_httpd.erl @@ -256,10 +256,16 @@ path(#httpd{mochi_req=MochiReq}) -> MochiReq:get(path). absolute_uri(#httpd{mochi_req=MochiReq}, Path) -> - Host = case MochiReq:get_header_value("Host") of + XHost = couch_config:get("httpd", "x_forwarded_host", "X-Forwarded-Host"), + Host = case MochiReq:get_header_value(XHost) of undefined -> - {ok, {Address, Port}} = inet:sockname(MochiReq:get(socket)), - inet_parse:ntoa(Address) ++ ":" ++ integer_to_list(Port); + case MochiReq:get_header_value("Host") of + undefined -> + {ok, {Address, Port}} = inet:sockname(MochiReq:get(socket)), + inet_parse:ntoa(Address) ++ ":" ++ integer_to_list(Port); + Value1 -> + Value1 + end; Value -> Value end, "http://" ++ Host ++ Path. |