Autostarting nginx

I'm having some trouble getting nginx (installed via opkg install nginx-all-module) to autostart. I've tried running

# /etc/init.d/nginx enable

and confirmed it's enabled

# /etc/init.d/nginx enabled && echo on
on

however when I reboot I still get

# /etc/init.d/nginx status
inactive

and nginx isn't serving anything. I confirmed it's symlinked in /etc/rc.d/

# ls -al /etc/rc.d/S80nginx
lrwxrwxrwx    1 root     root            15 Jan 14 13:54 /etc/rc.d/S80nginx -> ../init.d/nginx

Have I missed something obvious here? I'm not sure what else needs to be linked based on the documentation...

You need to check /etc/init.d/nginx. You will notice some hidden activity, i.e. usage of
'nginx-util', doing some configuration magic besides /etc/nginx.conf .

You might get more info about your problem when manually starting nginx from cmd line.
Just type 'nginx' after login to router.

1 Like

Have you disabled uhttpd first or are they colliding with nginx for the same port?

nginx doesn't seem to have any issues starting up normally, running nginx or /etc/init.d/nginx start both work without errors if I run them immediately after booting up.

I forgot to mention, I don't have nginx listening on port 80 I'm using it with nginx-rtmp so it's only binding to 1935. It has no problems if I bring it up manually.

I know it's an older topic but I have the same problem and use-case: I want to run nginx with RTMP on the Raspi that's running OpenWrt. Currently I'm struggling with the ports, as uhttpd and nginx fight over port 80.
Can you maybe share your configs and where you made which change? :slight_smile:

Don't enable in 22.03 will brick your device

DON'T!!!!
service nginx enable

I had same problem as yours, and I use stream module in nginx.conf, and the point is, for server there, CAN NOT BE domain, i changed the domain to IP address, nginx is running after reboot.

events{...}
stream {
    server {
        listen 1234;
        proxy_ssl on;
        proxy_ssl_protocols TLSv1.3;
        proxy_ssl_server_name on;
        proxy_ssl_name hello.world;
        proxy_pass VPS IP:5678;  # here must be IP other than domain

    }
}
http{...}