How to access video clip from vlc via uhttpd

Hello reinerotto,
I currently using lenovo Y1, 16Mb flash, 128Mb RAM.

Much more, than required for nginx to stream videos.
You might consider either to remove LuCI+uhttpd completely (preferred), or LuCi+uhttpd to be accessed using non-standard port, to avoid collisions.
Anyway, you might try to set up apache first, because its integration of php is easier to configure, compared to set up of nginx+php.

1 Like

Hello reinerotto,
In a first time I prefer a configuration with both uhttpd and nginx, because my server is running many other PHP scripts.

So I tried to setup nginx with a different port (90) but I get a 404 return code.
I created a new directory at root level:" html" with nogroup as group and nobody as user, this directory contains a very simple index.html file.
Regarding nginx I'm a true newbee, so could you have a look to my configuration files please ?

nginx.conf

user nobody nogroup;
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       90;
        server_name  FACTOTUM;

        location / {
            root   html;
            include    /etc/nginx/fastcgi.conf;
  					index    index.html index.htm index.php;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:90;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
}

fastcgi.conf

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

fastcgi_index  index.php;

fastcgi_param  REDIRECT_STATUS    200;

fastcgi_params

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  HTTPS              $https if_not_empty;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

Many thanks by advance for your help

Hello again reinerotto,

My work is inprogress, I can now reach my simple index.html page its contains was wrong with a redirection, that was probably the reason of 404 error !!!

Now I got an issue with this declaration in the nginx.conf:

location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:90;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi_params;
        }

I got a nginx error at start:

nginx: [error] open() "/var/run/nginx.pid" failed (2: No such file or directory)

But this file really exists at this place!

and the file permissions are .... ?

0644, but this file is dynamicaly created by nginx, no?
In spite of this error at start the server is still working well for html page but php script are not executed just listed by the browser ...

Yes, but if you'd have ran the daemon manually, as root, the nginx would have failed to create a new one, later, assuming it doesn't run as root, which is shouldn't.

Indeed the owner of this file is root and I was logged as root, but how can we explain that this error message at start does not occur if I delete those lines in nginx.conf ?

location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:90;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi_params;
        }

More information:

In nginx.conf, I restored this section:

location ~ \.php$ {
            root                  /html;
            fastcgi_pass    127.0.0.1:90;
            fastcgi_index   index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include             fastcgi_params;
        }

I added a "/" before the path for root parameters (/html instead of html) I don't know why, but the start error message disapear, I still log as root and nginx group is nogroup, nginx user is nobody , so it does not seems this message was due to a permission or owner file isue (?)

At this time, HTML pages are reachable but php scripts are still not found (404).

Probably a mistake in nginx.conf to activate php but where ?

You should ask on nginx forum, as it is not openwrt specific.
I told you, correct config of php for nginx not trivial.
You might start to set up nginx+php on real LINUX. And, when it works, to port to openwrt, not to be caught by openwrt-specialities.

Thanks reinerotto,
Youre right configuring nginx and php is not so easy!
I hev'nt a linux platform so it will be difficult for me to do what you propose.
As far I understood you made it for your own video streaming purpose so may you can give me some track to make this configuartion working ?

It was for a commercial project.
You can run ubuntu in a VM.

Ok, I see ..
So, for a commercial project the OS was probably not openwrt.
Anyway thanks to have tried to help me.

If you read the complete thread you probably know I'm currently working on another architecture:

Openwrt+miniDLNA to allow access my videos.

Development of an Android apps which include an upnpbrowser/player interfacing miniDLNA

I've almost finished ...

It was running on openwrt.
And also included browser based streaming of videos from the router, using opensource video player.
For Android browser and Safari. Streaming from nginx+php, as described already.

So ... good,

My choice is different, not using a conventionnal brother for windows, linux, ios or android for rendering videos but a dedicated Android apps which is able to interact with miniDLNA or other upnp/dlna device capable and browse and parse upnp devices present on the lan, and browse and parse xml upnp/dlna device stream, and present it with a nice GUI and play the videos gently.

The upnp device discover, parsing video gallery and playing video are ok, now I'm working to set up a nice GUI to present it, the player will be one of the one installed on the Android device hosting my application (user choice).

You've probably understood that this requires mostly Android skill than Openwrt. Nevertheless nginx could avoid me the development effort of an Android apps , but as it seems to be a bit complicated to build a nginx/php configuration ...

In this way I can continue to use my Openwrt servers just one of them has minidlna installed.