Closed joshobrienau closed 5 years ago
You may use the init.sh and clean.sh scripts to add the changes you need on boot / shutdown. See https://github.com/WDCommunity/wdpksrc/blob/master/wdpk/cops/init.sh which is installed to /shares/Volume_1/Nas_Prog/cops/init.sh
Thanks for the suggestion, but what specifically would I add to either init.sh or clean.sh to make it read .htaccess ?
Note: I'm not familiar with the .htaccess file, but you can use the init script to copy your custom .htaccess to the proper location and reload httpd if necessary.
kill -HUP $(pidof httpd)
This is how you can work around the revert on reboot.
I'm not following what you mean. I'm wanting to know how to make the .htaccess file in the cops/web directory to be read. Currently it's not being read.
What specifically am I changing in the init.sh file to make the .htaccess file being read?
I'll have to experiment with htaccess to get it to work. I thought you had it working, but had issues with the reset on reboot.. so I explained how to work around that reset.
No I haven't had it working, I was attempting to make a change to the http.config file to read the .htaccess file to see if that would work, but unfortunately on reboot WD resets the http.config to default, so I wasn't able to do via this method.
But essentially I'm just wanting to be able to use the .htaccess file within the Nas_Prog/cops/web directory on a WD NAS.
Well that's what I meant: in the init.sh you could copy your custom http.config and reload the webserver. Anyway, I've had a go at it with this excellent debugging tutorial: https://docs.bolt.cm/3.6/howto/making-sure-htaccess-works and I can assure that the .htaccess file in the cops directory gets picked up.
Ahh cool, can you copy and paste your entire init.sh file contents so I can try it on mine?
It seems like the auth modules do not work... but if you want to create some custom 404 pages it works.
Whats the script you've put in the init.sh file to make it read the .htaccess file in the cops directory?
Just create .htaccess with the contents 'test.' and you'll see it fail due to syntax error, proving it is not ignored. Or put "Deny from all" and you'll get access denied. You need AllowOverride All in the /var/www directory in httpd.conf.
I already have "test" at the top of the .htaccess file, which proves it's not being read.
Seem to be going in circles though, if you're saying you added a script to the init.sh file and now it works, what's script you added to the init.sh file to make it read the .htacces file.
There is no httpd.conf file in /var/www directory and if you place anything here, it's deleted on reboot, what steps did you do to create a persistent file here?
Currently it's not reading the .htaccess file, if you've found a way to resolve this, please provide the steps and the scripts so I can recreate on my end and test.
I was testing by creating a .htaccess directly in /var/www/cops, I didn't check the reboot behaviour as I didn't expect the bug to be in the init.sh. In init.sh the cops web dir is created /var/www/cops and it symlinks all files the directory... except for the hidden files such as the .htaccess file. That's how star expansion works.
I played a bit with /usr/local/apache2/conf/httpd.conf as well. My initial suggestion was to override whatever you needed by overwriting this httpd.conf in the cops init.sh. But that won't be necessary now.
I've tested it now and user/password auth works as expected. Get the new 0.04 package or patch (https://github.com/WDCommunity/wdpksrc/commit/89a152713c12f256198f523f24460ca18bbec8da) Create a .htpasswd file
htpasswd -c /shares/Volume_1/Nas_Prog/cops/someuser.pw someuser
Then change the .htaccess file in /var/www/cops/.htaccess
<FilesMatch "\.php$">
AuthUserFile /shares/Volume_1/Nas_Prog/cops/someuser.pw
AuthGroupFile /dev/null
AuthName "Acces securise"
AuthType Basic
Require valid-user
</FilesMatch>
Hmm.. there might be more to it than just this patch. It worked when I'd wiped most of /usr/local/apache2/conf/httpd.conf... but on reboot it's gone.
Yeah it's an interesting one, that's been my biggest issue.
Man I want this working so bad
I did remove the IP filters in /usr/local/apache2/conf/httpd.conf
<Directory />
AllowOverride All
</Directory>
<Directory "/var/www">
Options +FollowSymLinks -MultiViews -Indexes
AllowOverride All
</Directory>
Then I created a new user file (with a new random user even)
htpasswd -c /shares/Volume_1/Nas_Prog/cops/someuser.pw somerandomuser
On page reload in the browser, I get the password prompt. I don't know how to flush the browser cache / apache cache though.
I'll check if the httpd.conf changes are necessary.
It's great that it's now reading the .htaccess file, it works with just basic .htpasswd as in only username and password auth, IP auth is still not working however, the ideal is to have .htpasswd working with both user/password auth and IP auth on the COPS environment.
I'll close this for now as finetuning apache is slightly out of scope here. Please share your results if you find anything of interest!
In the case of COPS the .htaccess file is ignored on WD NAS. Can instructions be provided as to how to enable .htaccess within the COPS directory.
Using a PR2100 and have SSH knowledge, however anytime I modify the http.config or any other config, they are reverted after NAS reboot.
If anyone is able to provide how to enable .htaccess on WD NAS that would be amazing.