mirror of
https://github.com/jc21/nginx-proxy-manager.git
synced 2024-08-30 18:22:48 +00:00
Merge pull request #3388 from jlesage/reachability-test-fix
Fixes for the server reachability test.
This commit is contained in:
commit
bc8211a6a9
@ -1167,6 +1167,7 @@ const internalCertificate = {
|
|||||||
const options = {
|
const options = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
'User-Agent': 'Mozilla/5.0',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
'Content-Length': Buffer.byteLength(formBody)
|
'Content-Length': Buffer.byteLength(formBody)
|
||||||
}
|
}
|
||||||
@ -1179,12 +1180,22 @@ const internalCertificate = {
|
|||||||
|
|
||||||
res.on('data', (chunk) => responseBody = responseBody + chunk);
|
res.on('data', (chunk) => responseBody = responseBody + chunk);
|
||||||
res.on('end', function () {
|
res.on('end', function () {
|
||||||
const parsedBody = JSON.parse(responseBody + '');
|
try {
|
||||||
if (res.statusCode !== 200) {
|
const parsedBody = JSON.parse(responseBody + '');
|
||||||
logger.warn(`Failed to test HTTP challenge for domain ${domain}`, res);
|
if (res.statusCode !== 200) {
|
||||||
|
logger.warn(`Failed to test HTTP challenge for domain ${domain} because HTTP status code ${res.statusCode} was returned: ${parsedBody.message}`);
|
||||||
|
resolve(undefined);
|
||||||
|
} else {
|
||||||
|
resolve(parsedBody);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (res.statusCode !== 200) {
|
||||||
|
logger.warn(`Failed to test HTTP challenge for domain ${domain} because HTTP status code ${res.statusCode} was returned`);
|
||||||
|
} else {
|
||||||
|
logger.warn(`Failed to test HTTP challenge for domain ${domain} because response failed to be parsed: ${err.message}`);
|
||||||
|
}
|
||||||
resolve(undefined);
|
resolve(undefined);
|
||||||
}
|
}
|
||||||
resolve(parsedBody);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1198,6 +1209,9 @@ const internalCertificate = {
|
|||||||
if (!result) {
|
if (!result) {
|
||||||
// Some error occurred while trying to get the data
|
// Some error occurred while trying to get the data
|
||||||
return 'failed';
|
return 'failed';
|
||||||
|
} else if (result.error) {
|
||||||
|
logger.info(`HTTP challenge test failed for domain ${domain} because error was returned: ${result.error.msg}`);
|
||||||
|
return `other:${result.error.msg}`;
|
||||||
} else if (`${result.responsecode}` === '200' && result.htmlresponse === 'Success') {
|
} else if (`${result.responsecode}` === '200' && result.htmlresponse === 'Success') {
|
||||||
// Server exists and has responded with the correct data
|
// Server exists and has responded with the correct data
|
||||||
return 'ok';
|
return 'ok';
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
set $test "";
|
||||||
if ($scheme = "http") {
|
if ($scheme = "http") {
|
||||||
|
set $test "H";
|
||||||
|
}
|
||||||
|
if ($request_uri = /.well-known/acme-challenge/test-challenge) {
|
||||||
|
set $test "${test}T";
|
||||||
|
}
|
||||||
|
if ($test = H) {
|
||||||
return 301 https://$host$request_uri;
|
return 301 https://$host$request_uri;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user