Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE_REGUEST] Allow custom status codes for status checking #456

Closed
Lissy93 opened this issue Jan 28, 2022 Discussed in #448 · 6 comments
Closed

[FEATURE_REGUEST] Allow custom status codes for status checking #456

Lissy93 opened this issue Jan 28, 2022 Discussed in #448 · 6 comments
Assignees
Labels
🦄 Feature Request [ISSUE] Suggestion for new feature, update or change 🔨 Fixed 🛩️ Released 2.0.0

Comments

@Lissy93
Copy link
Owner

Lissy93 commented Jan 28, 2022

Discussed in #448

Originally posted by louisonsarlinmagnus January 27, 2022
In my Homelab I'm using Authelia as SSO.
Problem is that the statusCheck I get a red dot because of 401 return.
image

Is there a way to add a "rule" saying 401=>Green ?


Implementation

Most of these changes would need to be implemented in the backend, in status-check.js.

In the main export, add a line to get the accepted status codes, then pass it as a param to makeRequest(...)

const acceptCodes = decodeURIComponent(params.get('acceptCodes'));
...
makeRequest(url, headers, enableInsecure, acceptCodes, render);

In the catch block of makeRequest(...), check the status code, and if it's in the accepted range, then return the success message

if (validCodes && String(validCodes).includes(returnCode)) { // Success overridden by user
        const results = {
          successStatus: getResponseType(returnCode, validCodes),
          statusCode: returnCode,
          statusText: response.statusText,
          timeTaken: (new Date() - startTime),
        };
        results.message = makeMessageText(results);
        return results;
      }

In getResponseType(), add a param for validCodes, then check if actual code is found in expected codes

const getResponseType = (code, validCodes) => {
  if (validCodes && String(validCodes).includes(String(code))) return true;
  const numericCode = parseInt(code, 10);
  return (numericCode >= 200 && numericCode <= 302);
};

Then, in Item.vue, get the option from prop, convert to URL parameter and add it to the endpoint

const acceptCodes = statusCheckAcceptCodes ? `&acceptCodes=${statusCheckAcceptCodes}` : '';
...
return `${baseUrl}${serviceEndpoints.statusCheck}/${urlToCheck}`
        + `${headers}${enableInsecure}${acceptCodes}`;

And in Section.vue, pass the prop to the item

:statusCheckAcceptCodes="item.statusCheckAcceptCodes"
@liss-bot
Copy link
Collaborator

The fix for this issue has now been released in Dashy 2.0.0 ✨

If you haven't done so already, please update your instance to 2.0.0 or later. See Dashy 2.0.0 for full info.

Feel free to reach out if you need any more support. If you are enjoying Dashy, consider supporting the project.

@masterwishx
Copy link

How to set Dashy if i got answer from auth.mysite.com becose Authelia but i need like photo.mysite.com ?

@Lissy93
Copy link
Owner Author

Lissy93 commented Jun 8, 2022

https://github.com/Lissy93/dashy/blob/master/docs/status-indicators.md

🚀 A self-hosted startpage for your server. Easy to use visual editor, status checking, widgets, themes and tons more! - dashy/status-indicators.md at master · Lissy93/dashy

@Lissy93
Copy link
Owner Author

Lissy93 commented Jun 8, 2022

So it's not super clear what you're asking. But if you mean how to set accepted status codes, then you can do this with something like: statusCheckAcceptCodes: '403,418', see: Docs --> Status Checking --> Allowing Alternative Status Codes.

Or if you meant something else, then is probably covered in the troubleshooting section - there are lots of options you can set, so status checks to nearly all services should work.

It's been discussed before, but ping-only status checks are not supported directly in Dashy, see: #233
So for that, you'd need to write your own service (it's very simple, don't worry), to accept a GET request, ping what you need, then respond with 200.

@masterwishx
Copy link

masterwishx commented Jun 9, 2022

So it's not super clear what you're asking

Thanks for answer
i meaned how to ping photo.mysite.com not auth.mysite.com i was thinking that kuma make it by default by GET but founded in logs of Nginx Proxy Manager its also get 200 from auth.mysite.com, but 302 from photo.mysite.com
so i need to fix it also ....

maybe i can fix it by enter kuma,dash to nginx setting for ignoring when GET from them ....

It's been discussed before, but ping-only status checks are not supported directly in Dashy
i will check it

@masterwishx
Copy link

So for that, you'd need to write your own service (it's very simple, don't worry), to accept a GET request, ping what you need, then respond with 200.

can you explain ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🦄 Feature Request [ISSUE] Suggestion for new feature, update or change 🔨 Fixed 🛩️ Released 2.0.0
Projects
None yet
Development

No branches or pull requests

3 participants