LuCI not working, nginx reports missing /etc/nginx/luci_uwsgi.conf

Using UI, I tried cleaning up some packages related to nginx I installed a few days and which I thought had no effect. There was an error returned in the "Package remove" modal window containing log of removal process. I didn't pay too much attention and just closed it.

Now, trying to access 192.168.1.1 fails:

  1. I am redirected to http://192.168.1.1/cgi-bin/luci/
  2. I see an ERR_CONNECTION_REFUSED in Chrome.

Looking at /var/log/nginx/error.log I see this:

2020/05/02 08:12:20 [emerg] 2293#0: open() "/etc/nginx/luci_uwsgi.conf" failed (2: No such file or directory) in /etc/nginx/nginx.conf:47

Indeed, trying to find the file yields nothing:

root@OpenWrt:/# find / -name luci_uwsgi.conf
root@OpenWrt:/#

Seems like the file is missing. Is there any way to restore it? Perhaps someone could help me out by posting the contents of the file here (omitting any sensitive info, ofc)?

Interestingly, I tried doing what a post suggests here: Luci on nginx ssl - uwsgi connect error, e.g.:

cp /rom/etc/nginx/luci_uwsgi.conf /etc/nginx/luci_uwsgi.conf

But /rom/etc/nginx/luci_uwsgi.conf is missing :thinking:

Copied the config from Luci on nginx ssl - uwsgi connect error just to see if it gets me anywhere.

Restarted nginx, now I get a "502 Bad Gateway" page when visiting http://192.168.1.1/cgi-bin/luci/.

This is what nginx error log says this:

2020/05/02 08:29:21 [crit] 2402#0: *6 connect() to unix:////var/run/uwsgi.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.1.116, server: localhost, request: "GET /cgi-bin/luci/ HTTP/1.1", upstream: "uwsgi://unix:////var/run/uwsgi.sock:", host: "192.168.1.1", referrer: "http://192.168.1.1/"

No uwsgi.sock?

You can only get from the /rom what is included in the firmware image you flashed. If you installed nginx after you have flashed OpenWrt, this file will not be in /rom.

Have you tried simply reinstalling nginx?

Got it, thanks! Minus one mystery for me.

Btw, is there a way to know which packages are part of standard image I am using? I'm on Archer C7 V2, the image I flashed was this one.

I am growing convinced I messed something up with uwsgi / nginx / whatever. I am really curious how can I diagnoses this.

After getting uwsgi.sock error, it now seems to me that uwsgi process did not create it? So my assumption was: if I restart uwsgi service, it'll self-heal by restoring uwsgi.sock. Nope, not the case.

I do see files with names like luci-cgi_io.socket, luci-webui.socket and uwsgi.pid. No uwsgi.sock file in /var/run/ and anywhere in the system.

Copied contents of luci_uwsgi.conf config from here & restarted nginx. Getting this error now:

2020/05/02 08:51:34 [error] 2562#0: *1 connect() to unix:////var/run/luci-webui.socket failed (146: Unknown error) while connecting to upstream, client: 192.168.1.116, server: localhost, request: "GET /cgi-bin/luci/ HTTP/1.1", upstream: "uwsgi://unix:////var/run/luci-webui.socket:", host: "192.168.1.1", referrer: "http://192.168.1.1/"

Looks like there's no process listening on luci-webui.socket file or am I jumping to conclusions too quickly?

Running netstat reveals some processes listening on sockets, no mention of luci whatsoever. Running ps -w – same, there's no process with luci in its name.

With all manual changes in place, rebooting router helped. I can see WebUI now. I have no idea what it was.

Looking at netstat – same picture, no luci anywhere, and probably I'm doing wrong expecting it to be in the output.

Looking at ps w I notice one thing though:

root@OpenWrt:~# ps w | grep luc
 1883 root      3212 S    /usr/sbin/uwsgi --set die-on-idle=true --ini /etc/uwsgi/vassals/luci-webui.ini
 1884 root      3696 S    /usr/sbin/uwsgi --set die-on-idle=true --ini /etc/uwsgi/vassals/luci-webui.ini
 2333 root      1212 S    grep luc
root@OpenWrt:~#

The uwsgi wasn't there before reboot. So strange. I thought uwsgi was running before... No I wonder, why it started properly after a restart?

Where can I look at list of processes that start on router boot?