forked from cory/tildefriends
Make things workable with a reverse proxy in front.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4858 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
eacca9d2ab
commit
75cb9f7fd2
@ -648,7 +648,7 @@ async function blobHandler(request, response, blobId, uri) {
|
||||
}
|
||||
|
||||
if (!uri) {
|
||||
response.writeHead(303, {"Location": (request.client.tls ? 'https://' : 'http://') + request.headers.host + blobId + '/', "Content-Length": "0"});
|
||||
response.writeHead(303, {"Location": (request.client.tls ? 'https://' : 'http://') + (request.headers['x-forwarded-host'] ?? request.headers.host) + blobId + '/', "Content-Length": "0"});
|
||||
response.end();
|
||||
return;
|
||||
}
|
||||
@ -900,18 +900,19 @@ loadSettings().then(function() {
|
||||
httpd.all("", function default_http_handler(request, response) {
|
||||
let match;
|
||||
if (request.uri === "/" || request.uri === "") {
|
||||
let host = request.headers['x-forwarded-host'] ?? request.headers.host;
|
||||
try {
|
||||
for (let line of (gGlobalSettings.index_map || '').split('\n')) {
|
||||
let parts = line.split('=');
|
||||
if (parts.length == 2 && request.headers.host.match(new RegExp(parts[0], 'i'))) {
|
||||
response.writeHead(303, {"Location": (request.client.tls ? 'https://' : 'http://') + request.headers.host + parts[1], "Content-Length": "0"});
|
||||
if (parts.length == 2 && host.match(new RegExp(parts[0], 'i'))) {
|
||||
response.writeHead(303, {"Location": (request.client.tls ? 'https://' : 'http://') + host + parts[1], "Content-Length": "0"});
|
||||
return response.end();
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
response.writeHead(303, {"Location": (request.client.tls ? 'https://' : 'http://') + request.headers.host + gGlobalSettings.index, "Content-Length": "0"});
|
||||
response.writeHead(303, {"Location": (request.client.tls ? 'https://' : 'http://') + host + gGlobalSettings.index, "Content-Length": "0"});
|
||||
return response.end();
|
||||
} else if (match = /^(\/~[^\/]+\/[^\/]+)(\/?.*)$/.exec(request.uri)) {
|
||||
return blobHandler(request, response, match[1], match[2]);
|
||||
|
@ -620,7 +620,7 @@ static void _httpd_endpoint_static_stat(tf_task_t* task, const char* path, int r
|
||||
|
||||
static void _httpd_endpoint_static(tf_http_request_t* request)
|
||||
{
|
||||
if (_httpd_redirect(request))
|
||||
if (strncmp(request->path, "/.well-known/", strlen("/.well-known/")) && _httpd_redirect(request))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user