Giter Club home page Giter Club logo

Comments (6)

mwtzl avatar mwtzl commented on July 21, 2024 1

Thanks for that link, that must have been it!

Changing proxy_pass http://[::1]:7000$uri; in the relevant nginx config to proxy_pass http://[::1]:7000; seems to have fixed the problem!

Closing this as resolved.

from znc.

psychon avatar psychon commented on July 21, 2024

Is there another place ZNC logs to that I can find out more?

Depends on how exactly you run ZNC, but in general, running with --debug provides some output.

When trying to add or edit networks through the WebUI I get redirected to this 404 page:

Could you say something about the URL that your browser displays when you get this 404 page? I don't want to know the (possibly private) location of your web interface, but the relative URL for that. Specifically, which module are you accessing?

For example, if your browser were to display https://znc.in/foo/bar, I'd be interested in the /foo/bar part of this.

Another quick idea: What do the nginx logs say for this request? Perhaps there is something helpful in its access logs.

from znc.

mwtzl avatar mwtzl commented on July 21, 2024

I have provided the relevant part of my nginx log below. As you can see, the URL its trying to access is /mods/global/webadmin/addnetwork, but the same thing happens for editnetwork and delnetwork.

2003:d4:****:****:****:****:****:****- - [26/Apr/2024:09:35:34 +0000] "GET /mods/global/webadmin/addnetwork?user=*** HTTP/2.0" 404 269 "https://znc.***.***/mods/global/webadmin>

from znc.

psychon avatar psychon commented on July 21, 2024

Well... okay, I don't know what is going and would be interested in hints from znc --debug.

2003:d4:****:****:****:****:****:****- - [26/Apr/2024:09:35:34 +0000] "GET /mods/global/webadmin/addnetwork?user=*** HTTP/2.0" 404 269 "https://znc.***.***/mods/global/webadmin>

How do I have to read this? nginx got a request for /mods/global/webadmin/addnetwork?user=***, I guess. But the /mods/global/webadmin at the end confuses me.

Looking at the code, The requested module does not acknowledge web requests comes from here:

"The requested module does not acknowledge web requests");

This code is reached if a module "does nothing" in its OnWebRequest hook. The default implementation does nothing, but the implementation from webadmin definitely should do something:

znc/modules/webadmin.cpp

Lines 519 to 736 in 82e82f0

bool OnWebRequest(CWebSock& WebSock, const CString& sPageName,
CTemplate& Tmpl) override {
std::shared_ptr<CWebSession> spSession = WebSock.GetSession();
if (sPageName == "settings") {
// Admin Check
if (!spSession->IsAdmin()) {
return false;
}
return SettingsPage(WebSock, Tmpl);
} else if (sPageName == "adduser") {
// Admin Check
if (!spSession->IsAdmin()) {
return false;
}
return UserPage(WebSock, Tmpl);
} else if (sPageName == "addnetwork") {
CUser* pUser = SafeGetUserFromParam(WebSock);
// Admin||Self Check
if (!spSession->IsAdmin() &&
(!spSession->GetUser() || spSession->GetUser() != pUser)) {
return false;
}
if (!pUser) {
WebSock.PrintErrorPage(t_s("No such user"));
return true;
}
if (spSession->IsAdmin() || !spSession->GetUser()->DenySetNetwork()) {
return NetworkPage(WebSock, Tmpl, pUser);
}
WebSock.PrintErrorPage(t_s("Permission denied"));
return true;
} else if (sPageName == "editnetwork") {
CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock);
// Admin||Self Check
if (!spSession->IsAdmin() &&
(!spSession->GetUser() || !pNetwork ||
spSession->GetUser() != pNetwork->GetUser())) {
return false;
}
if (!pNetwork) {
WebSock.PrintErrorPage(t_s("No such user or network"));
return true;
}
return NetworkPage(WebSock, Tmpl, pNetwork->GetUser(), pNetwork);
} else if (sPageName == "delnetwork") {
CString sUser = WebSock.GetParam("user");
if (sUser.empty() && !WebSock.IsPost()) {
sUser = WebSock.GetParam("user", false);
}
CUser* pUser = CZNC::Get().FindUser(sUser);
// Admin||Self Check
if (!spSession->IsAdmin() &&
(!spSession->GetUser() || spSession->GetUser() != pUser)) {
return false;
}
if (spSession->IsAdmin() || !spSession->GetUser()->DenySetNetwork()) {
return DelNetwork(WebSock, pUser, Tmpl);
}
WebSock.PrintErrorPage(t_s("Permission denied"));
return true;
} else if (sPageName == "editchan") {
CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock);
// Admin||Self Check
if (!spSession->IsAdmin() &&
(!spSession->GetUser() || !pNetwork ||
spSession->GetUser() != pNetwork->GetUser())) {
return false;
}
if (!pNetwork) {
WebSock.PrintErrorPage(t_s("No such user or network"));
return true;
}
CString sChan = WebSock.GetParam("name");
if (sChan.empty() && !WebSock.IsPost()) {
sChan = WebSock.GetParam("name", false);
}
CChan* pChan = pNetwork->FindChan(sChan);
if (!pChan) {
WebSock.PrintErrorPage(t_s("No such channel"));
return true;
}
return ChanPage(WebSock, Tmpl, pNetwork, pChan);
} else if (sPageName == "addchan") {
CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock);
// Admin||Self Check
if (!spSession->IsAdmin() &&
(!spSession->GetUser() || !pNetwork ||
spSession->GetUser() != pNetwork->GetUser())) {
return false;
}
if (pNetwork) {
return ChanPage(WebSock, Tmpl, pNetwork);
}
WebSock.PrintErrorPage(t_s("No such user or network"));
return true;
} else if (sPageName == "delchan") {
CIRCNetwork* pNetwork = SafeGetNetworkFromParam(WebSock);
// Admin||Self Check
if (!spSession->IsAdmin() &&
(!spSession->GetUser() || !pNetwork ||
spSession->GetUser() != pNetwork->GetUser())) {
return false;
}
if (pNetwork) {
return DelChan(WebSock, pNetwork);
}
WebSock.PrintErrorPage(t_s("No such user or network"));
return true;
} else if (sPageName == "deluser") {
if (!spSession->IsAdmin()) {
return false;
}
if (!WebSock.IsPost()) {
// Show the "Are you sure?" page:
CString sUser = WebSock.GetParam("user", false);
CUser* pUser = CZNC::Get().FindUser(sUser);
if (!pUser) {
WebSock.PrintErrorPage(t_s("No such user"));
return true;
}
Tmpl.SetFile("del_user.tmpl");
Tmpl["Username"] = sUser;
return true;
}
// The "Are you sure?" page has been submitted with "Yes",
// so we actually delete the user now:
CString sUser = WebSock.GetParam("user");
CUser* pUser = CZNC::Get().FindUser(sUser);
if (pUser && pUser == spSession->GetUser()) {
WebSock.PrintErrorPage(
t_s("Please don't delete yourself, suicide is not the "
"answer!"));
return true;
} else if (CZNC::Get().DeleteUser(sUser)) {
WebSock.Redirect(GetWebPath() + "listusers");
return true;
}
WebSock.PrintErrorPage(t_s("No such user"));
return true;
} else if (sPageName == "edituser") {
CString sUsername = SafeGetUsernameParam(WebSock);
CUser* pUser = CZNC::Get().FindUser(sUsername);
if (!pUser) {
if (sUsername.empty()) {
pUser = spSession->GetUser();
} // else: the "no such user" message will be printed.
}
// Admin||Self Check
if (!spSession->IsAdmin() &&
(!spSession->GetUser() || spSession->GetUser() != pUser)) {
return false;
}
if (pUser) {
return UserPage(WebSock, Tmpl, pUser);
}
WebSock.PrintErrorPage(t_s("No such user"));
return true;
} else if (sPageName == "listusers" && spSession->IsAdmin()) {
return ListUsersPage(WebSock, Tmpl);
} else if (sPageName == "traffic") {
return TrafficPage(WebSock, Tmpl);
} else if (sPageName == "index") {
return true;
} else if (sPageName == "add_listener") {
// Admin Check
if (!spSession->IsAdmin()) {
return false;
}
return AddListener(WebSock, Tmpl);
} else if (sPageName == "del_listener") {
// Admin Check
if (!spSession->IsAdmin()) {
return false;
}
return DelListener(WebSock, Tmpl);
}
return false;
}

Well... unless you are accessing a page it does not understand. All the return falses here could reach the code path you are seeing. Most of them are admin checks ("A non-admin is trying to do something that only admins may do"). I will assume that this is not the case for you.

Anyway, for your addnetwork case, this is the relevant code:

znc/modules/webadmin.cpp

Lines 537 to 556 in 82e82f0

} else if (sPageName == "addnetwork") {
CUser* pUser = SafeGetUserFromParam(WebSock);
// Admin||Self Check
if (!spSession->IsAdmin() &&
(!spSession->GetUser() || spSession->GetUser() != pUser)) {
return false;
}
if (!pUser) {
WebSock.PrintErrorPage(t_s("No such user"));
return true;
}
if (spSession->IsAdmin() || !spSession->GetUser()->DenySetNetwork()) {
return NetworkPage(WebSock, Tmpl, pUser);
}
WebSock.PrintErrorPage(t_s("Permission denied"));
return true;

The Admin or self change-check could produce the error message you are seeing. Besides that, I don't see anything that could cause this (all the other paths should display an error message), but I might be missing something. This might also be a problem with the HTTP session getting lost.

Does the webadmin web page still shows your login name after clicking around a bit? The session magic uses cookies and that should still work behind a proxy. But perhaps "something" is going on with your proxy. Did you configure TrustedProxies?

Anyway, now I would be more interested in output from znc --debug when doing such a request.

from znc.

mwtzl avatar mwtzl commented on July 21, 2024

There is something weird going on with the webadmin for sure. The error happens when I'm trying to do changes on my own account, so while that one isn't an admin, it should still be allowed.

In fact, a different kind of silent error happens when trying to do stuff as admin from the webadmin interface. When trying to edit other accounts, I instead get redirected to the admin page instead. It shows /mods/global/webadmin/edituser?user=normalusername in the URL, but I'm clearly on the /mods/global/webadmin/edituser?user=admin page instead.

I have

TrustedProxy = 127.0.0.1
TrustedProxy = ::1

in my znc.conf.

I'll come back with znc --debug output later / tomorrow.

from znc.

psychon avatar psychon commented on July 21, 2024

Could it be that the ?user=foo part gets lost between the proxy and znc?

I don't really understand it, but Google sounds like this is a not-unusual problem: https://serverfault.com/questions/656380/nginx-proxy-pass-with-uri-modification

from znc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.