Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom install directory not working #803

Closed
4 tasks done
freakbsd opened this issue Feb 11, 2021 · 22 comments · Fixed by #813
Closed
4 tasks done

Custom install directory not working #803

freakbsd opened this issue Feb 11, 2021 · 22 comments · Fixed by #813

Comments

@freakbsd
Copy link

freakbsd commented Feb 11, 2021

Before submitting an issue

  • This is a bug report
  • I searched existing issues before opening this one
  • I checked the FAQ and Wiki before creating this issue
  • I have read and understand the issue reporting guidelines

Describe the bug
Normal installation (curl -sL https://install.raspap.com | bash), I changed only the directory where the webgui will be installed.

Your environment

RASPAP_LATEST=2.6.1

root@Galactus:/var/www/html# uname -a
Linux Galactus 5.10.11-v7l+ #1399 SMP Thu Jan 28 12:09:48 GMT 2021 armv7l GNU/Linux
root@Galactus:/var/www/html# cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

[snip] @billz removed installer output

I think the problem is the fact that 50-raspap-router.conf is not updated with custom install directory, something like:

$HTTP["url"] =~ "^/(?!(dist|app|ajax|config))." ==> $HTTP["url"] =~ "^$webroot_dir/(?!(dist|app|ajax|config))."

After this change the interface it is accesible, but only the main page. Any item in menu gives 404 error. In lighttpd log (after enabling accesslog) I can see the following:

2021-02-11 21:01:56: (mod_fastcgi.c.421) FastCGI-stderr: PHP Warning: parse_ini_file(/etc/raspap/hostapd.ini): failed to open stream: No such file or directory in /var/www/html/thanos/includes/wifi_functions.php on line 145
2021-02-11 21:01:56: (mod_fastcgi.c.421) FastCGI-stderr: PHP Warning: parse_ini_file(/etc/raspap/hostapd.ini): failed to open stream: No such file or directory in /var/www/html/thanos/includes/dashboard.php on line 182

I remember that in previous versions there was an hostapd.ini, not .conf.

Please accept my sincere apologies in advance if I should open another bug report for the following issue, but i will describe it here because this one is easy.

Another problem observed for a long time (at least 1 year) (i didn't followed the versions and/or diff them) is the fact that session.cookie_httponly it is not changed by installer, see below:

root@Galactus:/var/www/html# sed -i -E 's/^session.cookie_httponly\s*=\s*(0|([O|o]ff)|([F|f]alse)|([N|n]o))\s*$/session.cookie_httponly = 1/' /etc/php/7.3/cgi/php.ini
root@Galactus:/var/www/html# grep session.cookie_httponly /etc/php/7.3/cgi/php.ini
session.cookie_httponly =
root@Galactus:/var/www/html#

I am not a regex expert, but my solution for this one is:

sed -i 's/session.cookie_httponly =/session.cookie_httponly = 1/g' /etc/php/7.3/cgi/php.ini

Simple.

Thank you.

@billz
Copy link
Member

billz commented Feb 12, 2021

URL rewrites were introduced in the latest release. @mp03 this should affect your implementation as well.

@mp035
Copy link

mp035 commented Feb 15, 2021

I have just tested an install with custom install directory (/var/www/html/raspap) and it seems to work fine. It should be noted that the user needs to make sure their lighttpd config (at /etc/lighttpd/lighttpd.conf) has the correct server.document-root setting which matches the install folder. The installer does not change the document-root, and I don't think that it should because the most obvious use case for a custom install directory is for a shared http server, in which case it is wise to leave the lighttpd config untouched. @billz could you weigh in on whether I am understanding this correctly?

@billz
Copy link
Member

billz commented Feb 15, 2021

@mp035 I believe the issue here is that prior to introducing URL rewrites, any subdir of the default /var/www/html webroot was accessible from the browser, eg., http://raspberrypi.local/raspap/ without touching the lighttpd config. @freakbsd can you confirm this?

@freakbsd
Copy link
Author

@billz @mp035

Yes, I confirm, I never touch lighttpd.conf after installing the raspap, everything simply worked.
I just instaled 2.5.2 and as usual, i don't do anything else to lighttpd/raspap configs.

Thanks

@freakbsd
Copy link
Author

freakbsd commented Feb 15, 2021

@mp035

When installing raspap, lighttpd is also installed with default settings which means that server.document-root it is always /var/www/html.
From my initial report, see below:


I think the problem is the fact that 50-raspap-router.conf is not updated with custom install directory, something like:

$HTTP["url"] =~ "^/(?!(dist|app|ajax|config))." ==> $HTTP["url"] =~ "^$webroot_dir/(?!(dist|app|ajax|config))."

After this change the interface it is accesible, but only the main page. Any item in menu gives 404 error. In lighttpd log (after enabling accesslog) I can see the following:**

2021-02-11 21:01:56: (mod_fastcgi.c.421) FastCGI-stderr: PHP Warning: parse_ini_file(/etc/raspap/hostapd.ini): failed to open stream: No such file or directory in /var/www/html/thanos/includes/wifi_functions.php on line 145
2021-02-11 21:01:56: (mod_fastcgi.c.421) FastCGI-stderr: PHP Warning: parse_ini_file(/etc/raspap/hostapd.ini): failed to open stream: No such file or directory in /var/www/html/thanos/includes/dashboard.php on line 182

As I said, i am not rewrite/regexp expert, but something it is not right here.

Thanks,

@freakbsd freakbsd reopened this Feb 15, 2021
@billz
Copy link
Member

billz commented Feb 15, 2021

Modifying 50-raspap-router.conf as @freakbsd suggests loads the main page, but the url-rewrite fails to load other hrefs.
The PHP warning raised by parse_ini_file is a relatively minor issue that is unrelated to this. I'll address it separately.

@mp035
Copy link

mp035 commented Feb 16, 2021

Fixed in 0cfdfd3.

@freakbsd
Copy link
Author

I will test today and I will come back with updates.
Thank you @mp035

@freakbsd
Copy link
Author

Hi guys,

Apologies for late answer.

I checked https://github.com/RaspAP/raspap-webgui/tree/0cfdfd367529db93bc83fb2d461434f3a2bf28ac and I took only https://github.com/RaspAP/raspap-webgui/blob/0cfdfd367529db93bc83fb2d461434f3a2bf28ac/config/50-raspap-router.conf. (i didn't saw any other change except for installers/common.sh)

The new lighttpd configuration works, so the custom directory is fine, but no other menu links work, all links only lead to the dasboard. So in the end it's a rewrite issue? @mp035 can you please test more ?

Thank you.

@billz
Copy link
Member

billz commented Feb 22, 2021

Also tested and found the following #749 (comment)

@mp035
Copy link

mp035 commented Mar 2, 2021

You need both the 50-raspap-router.conf and the changes to the installer. The installer will modify 50-raspap-router.conf as required during the install process.

billz added a commit that referenced this issue Mar 2, 2021
@freakbsd
Copy link
Author

freakbsd commented Mar 2, 2021

@mp035 see my comment.
I took 50-raspap-router.conf directly after checking your changes in common.sh.and I confirmed that your changes were okay, but new behavior was observed.

Ok, I wasn't clear, so I took 50-raspap-router.conf directly and, of course, adapted to my needs (REPLACE_ME => custom), so that's why I said that the new lighttpd configuration is ok (no need to take custom.sh)

I don't think that was enough, and I see that Billz has discovered other related issues.

Anyway, at the moment I am happy with 2.5.2 until you completely fix 2.6.x.

Thank you for your great work @billz @mp035 .

@billz billz closed this as completed in #813 Mar 3, 2021
@billz
Copy link
Member

billz commented Mar 3, 2021

@freakbsd thank you for reporting this and helping us to resolve it!

@tefracky
Copy link

tefracky commented May 7, 2021

Hey,
I am completely new to RaspAP and I have the same error as described. I installed RaspAP using curl -sL https://install.raspap.com | bash and choosed /var/www/html/raspap as path. Normally I use nginx as webserver, but error 404 occurs at every page but the start page. Then I tried to use lighttpd at port 81 and it is still not working.

It seems you resolved the problem, but I didn't understand. What exactly have I to do?

@etalon
Copy link

etalon commented May 9, 2021

Hey,
I am completely new to RaspAP and I have the same error as described. I installed RaspAP using curl -sL https://install.raspap.com | bash and choosed /var/www/html/raspap as path. Normally I use nginx as webserver, but error 404 occurs at every page but the start page. Then I tried to use lighttpd at port 81 and it is still not working.

It seems you resolved the problem, but I didn't understand. What exactly have I to do?

I am facing exactly the same error. I also have chosen the same path.

@etalon
Copy link

etalon commented May 9, 2021

I solved it with the comments here: #866

My 50-raspap-router.conf looked like this:

`server.modules += (
	"mod_rewrite",
)

$HTTP["url"] =~ "^_raspap/(?!(dist|app|ajax|config)).*" {
    url.rewrite-once = ( "^_raspap/(.*?)(\?.+)?$"=>"_raspap/index.php/$1$2" )
    server.error-handler-404 = "_raspap/index.php"
}`

And i changed it to this:

`server.modules += (
	"mod_rewrite",
)

$HTTP["url"] =~ "^/raspap/(?!(dist|app|ajax|config)).*" {
    url.rewrite-once = ( "^/raspap/(.*?)(\?.+)?$"=>"/raspap/index.php/$1$2" )
    server.error-handler-404 = "/raspap/index.php"
}`

As you will notice it looks like that the installer is inserting the folder not with a pipe. Instead it inserted a underscore.
You should not edit your lighttpd.conf to a other document root. Instead call the Url http://localhost/raspap/.
This worked for me.

@tefracky
Copy link

Thanks a lot! First I changed the root directory of lighttpd to /var/www/html/raspap, but it didn't work. The root directory must be /var/www/html and then http://ip-address:81/raspap is working without further changes.

@billz
Copy link
Member

billz commented May 10, 2021

@mp035 are you able to repo the above?

@mp035
Copy link

mp035 commented May 11, 2021

I'll take a look at it and try to work out why it's not replacing correctly.

@mp035
Copy link

mp035 commented May 17, 2021

@billz I am unable to reproduce this.
I started with a fresh install of raspberry pi OS lite, enabled ssh and WiFi by placing the appropriate files in the /boot partition.
Logged in via SSH:

pi@raspberrypi:~ $ curl -sL https://install.raspap.com | bash


 888888ba                              .d888888   888888ba
 88     8b                            d8     88   88     8b
a88aaaa8P' .d8888b. .d8888b. 88d888b. 88aaaaa88a a88aaaa8P
 88    8b. 88    88 Y8ooooo. 88    88 88     88   88
 88     88 88.  .88       88 88.  .88 88     88   88
 dP     dP  88888P8  88888P  88Y888P  88     88   dP
                             88
                             dP      version 2.6.5

The Quick Installer will guide you through a few easy steps


RaspAP Install: Configure installation
Detected OS: Raspbian GNU/Linux 10 (buster)
Using GitHub repository: RaspAP/raspap-webgui 2.6.5 branch
Configuration directory: /etc/raspap
lighttpd root: /var/www/html? [Y/n]: n
Enter alternate lighttpd directory: /var/www/html/raspap
Installing lighttpd directory: /var/www/html/raspap
Complete installation with these values? [Y/n]: 
RaspAP Install: Updating sources

Accessing the web gui worked after install, and:

pi@raspberrypi:~ $ cat /etc/lighttpd/conf-enabled/50-raspap-router.conf 
server.modules += (
	"mod_rewrite",
)

$HTTP["url"] =~ "^/raspap/(?!(dist|app|ajax|config)).*" {
    url.rewrite-once = ( "^/raspap/(.*?)(\?.+)?$"=>"/raspap/index.php/$1$2" )
    server.error-handler-404 = "/raspap/index.php"
}

pi@raspberrypi:~ $ 

Attached is a full transcript of the install process.
install_transcript.txt

@billz
Copy link
Member

billz commented May 17, 2021

@mp035 thanks for checking, I was also unable to repro this.
@etalon it's unclear how your file ended up with an underscore (_) unless it was specified during the install.

@commassoc
Copy link

Hello,
I have exactly the same problem, I receive an 404 error for all main menu items in case using an alternate lighttpd root. I want to use an alternate root because I use at the same time nginx web server and nginx use also /var/www/html as a default web site. Of course I've change the port for lighttpd (=>8080).
My solution is to use the default installation of raspap, install nginx before raspap et move the default nginx index (index.nginx-debian.html) to an other location. This means also modifying the default root for nginx (sites-available default)
Best Regard,
AR

@RaspAP RaspAP locked as resolved and limited conversation to collaborators Jun 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants