mirror of
https://github.com/aljazceru/cyphernode.git
synced 2026-02-02 03:04:19 +01:00
Moved statuspage from proxy to gatekeeper and refactored correctly
This commit is contained in:
@@ -10,7 +10,8 @@ server {
|
||||
location /status {
|
||||
auth_basic "status";
|
||||
auth_basic_user_file conf.d/status/htpasswd;
|
||||
proxy_pass http://proxy:8888;
|
||||
root /etc/nginx/conf.d;
|
||||
index statuspage.html;
|
||||
}
|
||||
|
||||
location / {
|
||||
|
||||
53
api_auth_docker/statuspage.html
Normal file
53
api_auth_docker/statuspage.html
Normal file
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
trace=true;
|
||||
|
||||
function log() {
|
||||
if (trace) {
|
||||
console.log(arguments.callee.caller.name, arguments.callee.caller.arguments);
|
||||
}
|
||||
}
|
||||
|
||||
function httpget(url) {
|
||||
log();
|
||||
|
||||
return fetch(url, { method: "GET" })
|
||||
.catch(err => {
|
||||
console.log('HTTP GET Error: ' + err.message + ' :: STACK : ' + err.stack);
|
||||
$("#result").text((JSON.stringify(err.message)));
|
||||
return Promise.reject(err.message);
|
||||
})
|
||||
.then(res => {
|
||||
if (!res.ok) {
|
||||
return res.json().then(data => {
|
||||
console.log('HTTP GET Error: ' + data.error.message);
|
||||
$("#result").text(JSON.stringify(data.error.message));
|
||||
return Promise.reject(data.error.message);
|
||||
});
|
||||
}
|
||||
return res.json();
|
||||
})
|
||||
.then(data => Promise.resolve(JSON.stringify(data)))
|
||||
}
|
||||
|
||||
function installation_status() {
|
||||
log();
|
||||
httpget("installation.json")
|
||||
.then(result => {
|
||||
$("#result").text(result);
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<button onclick="installation_status();">Installation Status</button>
|
||||
<p/>
|
||||
<pre lang="xml" id="result" style="white-space: pre-wrap"></pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -14,6 +14,7 @@ services:
|
||||
- "<%= gatekeeper_datapath %>/keys.properties:/etc/nginx/conf.d/keys.properties"
|
||||
- "<%= gatekeeper_datapath %>/api.properties:/etc/nginx/conf.d/api.properties"
|
||||
- "<%= gatekeeper_datapath %>/htpasswd:/etc/nginx/conf.d/status/htpasswd"
|
||||
- "<%= gatekeeper_datapath %>/installation.json:/etc/nginx/conf.d/status/installation.json"
|
||||
command: $USER
|
||||
|
||||
# deploy:
|
||||
|
||||
@@ -15,7 +15,7 @@ docker-compose -f $current_path/docker-compose.yaml up -d --remove-orphans
|
||||
docker run --rm -it -v $current_path/testfeatures.sh:/testfeatures.sh \
|
||||
-v $current_path/gatekeeper/keys.properties:/keys.properties \
|
||||
-v $current_path/gatekeeper/cert.pem:/cert.pem \
|
||||
-v <%= proxy_datapath %>:/proxy \
|
||||
-v <%= gatekeeper_datapath %>:/gatekeeper \
|
||||
--network cyphernodenet alpine:3.8 /testfeatures.sh
|
||||
|
||||
echo "Point your favorite browser to one of the following URLs to access Cyphernode's status page:"
|
||||
|
||||
@@ -311,6 +311,6 @@ result="${result}$(feature_status ${returncode} 'Lightning error!')}"
|
||||
|
||||
result="{${result}]}"
|
||||
|
||||
echo "${result}" > /proxy/installation.json
|
||||
echo "${result}" > /gatekeeper/installation.json
|
||||
|
||||
echo -e "\r\n\e[1;32mTests finished.\e[0m" > /dev/console
|
||||
|
||||
@@ -244,12 +244,6 @@ main()
|
||||
serve_ots_getfile $(echo "${line}" | cut -d ' ' -f2 | cut -d '/' -f3)
|
||||
break
|
||||
;;
|
||||
status)
|
||||
# curl (GET) http://192.168.111.152:8080/status
|
||||
|
||||
status_page
|
||||
break
|
||||
;;
|
||||
esac
|
||||
break
|
||||
fi
|
||||
|
||||
@@ -18,7 +18,7 @@ response_to_client()
|
||||
echo -en "Content-Type: ${contenttype}\r\nContent-Length: ${#response}\r\n\r\n${response}"
|
||||
|
||||
# Small delay needed for the data to be processed correctly by peer
|
||||
sleep 0.2s
|
||||
sleep 0.5s
|
||||
}
|
||||
|
||||
htmlfile_response_to_client()
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ./trace.sh
|
||||
. ./responsetoclient.sh
|
||||
|
||||
status_page() {
|
||||
cat <<EOF > statuspage.html
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
Hello from Cyphernode!<p/>
|
||||
EOF
|
||||
|
||||
cat db/installation.json >> statuspage.html
|
||||
|
||||
cat <<EOF >> statuspage.html
|
||||
</body>
|
||||
</html>
|
||||
EOF
|
||||
|
||||
htmlfile_response_to_client ./ statuspage.html
|
||||
}
|
||||
Reference in New Issue
Block a user