Issue 1:
Context

I have a neo4j dashboard (7474) behind a reverse proxy binded on https (443)

What I get

When trying to access the dashboard from https I get redirected to http

curl -ILk 'https://neo4j-redirect-issue/' -H 'Accept: text/html'
HTTP/1.1 303 See Other
Location: https://neo4j-redirect-issue/browser
Content-Type: text/html
Access-Control-Allow-Origin: *
Server: Jetty(9.0.5.v20130815)

HTTP/1.1 302 Found
Location: http://neo4j-redirect-issue/browser/
Server: Jetty(9.0.5.v20130815)

curl: (7) Failed to connect to neo4j-redirect-issue port 80: Connection refused

Here we see the scheme is kept in the first 303 redirect, but lost in the next 302 (when adding the trailing slash).

What I expect

I expect the scheme to be kept along all redirects so a call to https://neo4j-redirect-issue/ end up to https://neo4j-redirect-issue/browser/

Issue 2:
Webadmin interface doesn't use the X-Forwarded-Host and X-Forwarded-Proto headers to generate URLs. The URLs are correctly generated in the REST interface.

With 1.9.4

A basic query

$ curl -i -H 'X-Forwarded-Host: external.foo.bar:1234' -H 'X-Forwarded-Proto: https' localhost:7474/db/data/
HTTP/1.1 200 OK
Content-Length: 876
Content-Type: application/json; charset=UTF-8
Access-Control-Allow-Origin: *
Server: Jetty(6.1.25)

{
"extensions" : {
"CypherPlugin" : {
"execute_query" : "https://external.foo.bar:1234/db/data/ext/CypherPlugin/graphdb/execute_query"
},
"GremlinPlugin" : {
"execute_script" : "https://external.foo.bar:1234/db/data/ext/GremlinPlugin/graphdb/execute_script"
}
},
"node" : "https://external.foo.bar:1234/db/data/node",
"reference_node" : "https://external.foo.bar:1234/db/data/node/0",
"node_index" : "https://external.foo.bar:1234/db/data/index/node",
"relationship_index" : "https://external.foo.bar:1234/db/data/index/relationship",
"extensions_info" : "https://external.foo.bar:1234/db/data/ext",
"relationship_types" : "https://external.foo.bar:1234/db/data/relationship/types",
"batch" : "https://external.foo.bar:1234/db/data/batch",
"cypher" : "https://external.foo.bar:1234/db/data/cypher",
"neo4j_version" : "1.9.4"
}

A request simulating a browser

$ curl -i -H 'Accept: text/html' -H 'X-Forwarded-Host: external.foo.bar:1234' -H 'X-Forwarded-Proto: https' localhost:7474/db/data/
HTTP/1.1 200 OK
Content-Length: 1195
Content-Type: text/html; charset=UTF-8
Access-Control-Allow-Origin: *
Server: Jetty(6.1.25)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><title>Root</title><meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<link href='http://resthtml.neo4j.org/style/rest.css' rel='stylesheet' type='text/css'>
<script type='text/javascript' src='/webadmin/htmlbrowse.js'></script>
</head>
<body onload='javascript:neo4jHtmlBrowse.start();' id='root'>
<div id='content'><div id='header'><h1><a title='Neo4j REST interface' href='/'><span>Neo4j REST interface</span></a></h1></div>
<div id='page-body'>
<table class="root"><caption>Root</caption>
<tr class='odd'><th>relationship_index</th><td><a href="https://external.foo.bar:1234/db/data/index/relationship">https://external.foo.bar:1234/db/data/index/relationship</a></td></tr>
<tr><th>node_index</th><td><a href="https://external.foo.bar:1234/db/data/index/node">https://external.foo.bar:1234/db/data/index/node</a></td></tr>
<tr class='odd'><th>reference_node</th><td><a href="https://external.foo.bar:1234/db/data/node/0" class="node">https://external.foo.bar:1234/db/data/node/0</a></td></tr>
</table>
<div class='break'>&nbsp;</div></div></div></body></html>

In both cases, the URLs are https://external.foo.bar:1234/...

However, if we try to get the webadmin interface:

$ curl -i -H 'Accept: text/html' -H 'X-Forwarded-Host: external.foo.bar:1234' -H 'X-Forwarded-Proto: https' localhost:7474
HTTP/1.1 303 See Other
Location: http://localhost:7474/webadmin
Content-Type: text/html
Access-Control-Allow-Origin: *
Content-Length: 0
Server: Jetty(6.1.25)

$ curl -i -H 'Accept: text/html' -H 'X-Forwarded-Host: external.foo.bar:1234' -H 'X-Forwarded-Proto: https' localhost:7474/webadmin
HTTP/1.1 302 Found
Location: http://localhost:7474/webadmin/
Content-Length: 0
Server: Jetty(6.1.25)

In both cases, the generated URL is http://localhost:7474/

With 2.0.0-M06

The same behaviour is found in 2.0.0-M06

$ curl -i -H 'Accept: text/html' -H 'X-Forwarded-Host: external.foo.bar:1234' -H 'X-Forwarded-Proto: https' localhost:7474/
HTTP/1.1 303 See Other
Location: http://localhost:7474/browser
Content-Type: text/html
Access-Control-Allow-Origin: *
Content-Length: 0
Server: Jetty(9.0.5.v20130815)

$ curl -i -H 'Accept: text/html' -H 'X-Forwarded-Host: external.foo.bar:1234' -H 'X-Forwarded-Proto: https' localhost:7474/db/data/
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Access-Control-Allow-Origin: *
Content-Length: 1195
Server: Jetty(9.0.5.v20130815)

[...] <a href="https://external.foo.bar:1234/db/data/node/0" class="node">https://external.foo.bar:1234/db/data/node/0</a></td></tr>
</table>