Giter Club home page Giter Club logo

Comments (5)

kimbtech avatar kimbtech commented on July 20, 2024

Hi,

my example of rewrite ^(.*)$ /index.php?uri=$1 last; is for NGINX. And NGINX does not add url parameters like ?token=0 or ?sSearchtype=3&Search=... to the variable $1. These parameters are stored and passed to PHP using other variables.

Thus, I my example $1 would only contain /setupapp/fs/asp/BrowseXML/loginXML.asp or /setupapp/fs/asp/BrowseXML/Search.asp.

I am not very experienced with lighttpd, but i assume a simple
url.rewrite-if-not-file = ( "" => "/index.php?uri=${url.path}" )
should do it (https://redmine.lighttpd.net/projects/lighttpd/wiki/Mod_rewrite).
${url.query} should contain the query terms like sSearchtype=3&Search=..., which need to be send to php separately or if this is not the case, then url.rewrite-if-not-file = ( "" => "/index.php?path=${url.path}&${url.query}" ) might work.

from radio-api.

lefevred avatar lefevred commented on July 20, 2024

interesting, trying the second option, I get error 500 :(
xx.xx.xx.xx pri.logon.wifiradiofrontier.com - [16/Feb/2024:18:03:42 +0100] "GET /setupapp/fs/asp/BrowseXML/loginXML.asp?token=0 HTTP/1.0" 500 0 "-" "FS NS/1.0"
xx.xx.xx.xx pri.logon.wifiradiofrontier.com - [16/Feb/2024:18:03:42 +0100] "GET /setupapp/fs/asp/BrowseXML/loginXML.asp?token=0 HTTP/1.0" 500 0 "-" "FS NS/1.0"

Is there a way to find out in PHP what is generating this 500 ?

and then http 303

xx.xx.xx.xx pri.logon.wifiradiofrontier.com - [16/Feb/2024:18:03:42 +0100] "GET /setupapp/fs/asp/BrowseXML/Search.asp?sSearchtype=3&Search=a680a4929eb0d0a25ee9782d39aebe3e&mac=&dlang=eng&fver=7 HTTP/1.0" 303 0 "-" "FS NS/1.0"
xx.xx.xx.xx radio.web.ui - [16/Feb/2024:18:03:42 +0100] "GET /gui/view.php?redirFromIndex HTTP/1.0" 200 2300 "-" "FS NS/1.0"

from radio-api.

kimbtech avatar kimbtech commented on July 20, 2024

Hi,

Lighttpd or PHP fpm should create some PHP error logs. But the location depends on the setup.
You may also check the troubleshooting section of Radio-API.

I just tried to run Radio-API via Lighttpd, for me url rewriting works with this line:
url.rewrite-if-not-file = ( "[^\/](\?.*)$" => "/index.php?uri=${url.path}&${url.query}" )


Just more info about my test, I used a Docker container with Lighttpd besides one with PHP fpm:

version: "2"

services:
  server:
    image: jitesoft/lighttpd:latest-cgi
    restart: "no"
    ports:
      - "8080:80"
    environment:
      - PORT=80
      - SERVER_NAME=localhost
      - SERVER_ROOT=/var/www/html
      - CONFIG_FILE=/etc/lighttpd/lighttpd.conf
      - SKIP_HEALTHCHECK=true
      - CGI_HOST=phpfpm
      - CGI_PORT=9000
      - CHECK_LOCAL=enable
      - CGI_FILE_EXT=.php
    volumes:
      - ./php/:/var/www/html/ # just mount Radio-API from the Radio-API Source
      - ./urlrewrite.conf:/etc/lighttpd/conf.d/urlrewrite.conf 
    depends_on:
      - phpfpm
  phpfpm:
    image: php:8-fpm-alpine
    restart: "no"
    volumes:
      - ./php/:/var/www/html/

Whereas urlrewrite.conf only contained one like

url.rewrite-if-not-file = ( "[^\/](\?.*)$" => "/index.php?uri=${url.path}&${url.query}" )

from radio-api.

lefevred avatar lefevred commented on July 20, 2024

Thanks for the tips, that is very useful !

I'm not using the docker install version but the manual version on Armv7l, and I've noticed by asking PHP to show errors that it needs the php-mbstring package.

I had several messages like this :

FastCGI-stderr:PHP message: PHP Fatal error: Uncaught Error: Call to undefined function mb_substitute_character() in /media/localbackup/web/Radio-API-2.8.2/php/classes/Output.php:17

installing the missing package

apt install php-mbstring

using the last regex in lighttpd config, I see :

2024-02-17 10:20:38: (response.c.420) -- parsed Request-URI
2024-02-17 10:20:38: (response.c.422) Request-URI : /setupapp/fs/asp/BrowseXML/loginXML.asp?token=0
2024-02-17 10:20:38: (response.c.424) URI-scheme : http
2024-02-17 10:20:38: (response.c.426) URI-authority : pri.logon.wifiradiofrontier.com
2024-02-17 10:20:38: (response.c.428) URI-path (clean): /setupapp/fs/asp/BrowseXML/loginXML.asp
2024-02-17 10:20:38: (response.c.430) URI-query : token=0
2024-02-17 10:20:38: (response.c.420) -- parsed Request-URI
2024-02-17 10:20:38: (response.c.422) Request-URI : /index.php?uri=/setupapp/fs/asp/BrowseXML/loginXML.asp&token=0
2024-02-17 10:20:38: (response.c.424) URI-scheme : http
2024-02-17 10:20:38: (response.c.426) URI-authority : pri.logon.wifiradiofrontier.com
2024-02-17 10:20:38: (response.c.428) URI-path (clean): /index.php
2024-02-17 10:20:38: (response.c.430) URI-query : uri=/setupapp/fs/asp/BrowseXML/loginXML.asp&token=0
2024-02-17 10:20:38: (response.c.509) -- logical -> physical
2024-02-17 10:20:38: (response.c.511) Doc-Root : /srv/Radio-API-2.8.2/php/
2024-02-17 10:20:38: (response.c.513) Basedir : /srv/Radio-API-2.8.2/php/
2024-02-17 10:20:38: (response.c.515) Rel-Path : /index.php
2024-02-17 10:20:38: (response.c.517) Path : /srv/Radio-API-2.8.2/php/index.php
2024-02-17 10:20:38: (response.c.536) -- handling subrequest
2024-02-17 10:20:38: (response.c.538) Path : /srv/Radio-API-2.8.2/php/index.php
2024-02-17 10:20:38: (response.c.540) URI : /index.php
2024-02-17 10:20:38: (response.c.542) Pathinfo :
2024-02-17 10:20:38: (gw_backend.c.2674) handling the request using fastcgi
2024-02-17 10:20:38: (response.c.179) fd:17 resp: HTTP/1.0 200 OK

xxx.xx.xx.xx pri.logon.wifiradiofrontier.com - [17/Feb/2024:10:20:38 +0100] "GET /setupapp/fs/asp/BrowseXML/loginXML.asp?token=0 HTTP/1.0" 200 49 "-" "FS NS/1.0"

which is better 👍

I have "Marshall radios devices" which have no screen on them, but the
And, now, I can see the login code in the Mashall App for my device !
Browsing to the radios, I can see all of them !

MANY THANKS for your hints, this was really helpfull !

from radio-api.

kimbtech avatar kimbtech commented on July 20, 2024

Hi,
I am glad that it works now. I have added mbstring to the setup.md.

from radio-api.

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.