Difference between revisions of "MythWeb"

From MythTV Official Wiki
Jump to: navigation, search
(Time Stamp is off by an hour)
(Time Stamp is off by an hour)
Line 400: Line 400:
  
 
sudo apt-get install php-pear
 
sudo apt-get install php-pear
 +
 
sudo pecl install timezonedb
 
sudo pecl install timezonedb
  

Revision as of 23:48, 5 October 2008

MythWeb

MythWeb provides a frontend for scheduling and managing recordings on your MythBox from a web browser located on another machine. Provided the security is set up correctly on your MythBox you can access your machine from anywhere on the internet, or even your mobile phone as long as you have a compatible browser. Of course it is just as useful to browse your myth content from your laptop while your partner is watching their favorite programme.

Mythweb also has some unique capabilities that are only available through the web interface such as allowing for the change of key bindings and other settings.

Indeed, many functions you might want to perform on your MythBox are faster or easier through MythWeb. (How much this is true, of course, depends to some degree on what version you're running.)

See MythWeb INSTALL for details on how to install. (Note this is hard linked to the 0.21-fixes version of this docuemnt)

MythWeb is currently being rewritten to support streaming of content via Flash

One contributed favicon is File:Favicon.jpg (it's really a .ico file; see the page).

Here is another favicon.

Key Features

TV

Programme Listing

Special Searches

Upcoming Recordings

Recording Schedules

Schedule Manually

Custom Schedule

Recorded Programmes

Music

Browse your Music Collection and download to your local machine for direct playback

Video

Browse your Video collection and download to your local machine

Weather

Get weather reports as per MythWeather.

Status

Show the Backend Status Logs such as how much disk space and tuners that are recording

Statistics

Show key statistics such as Top Recorded Shows

Logs

Show the Server Logs

Settings

Configure MythWeb and some of the MythTV settings.

MythWeb session settings

MythTV global defaults

MythTV channel info

MythTV key bindings

MythTV settings table

Gallery

Grease Monkey Scripts

To enhance your MythWeb experience:


Securing Mythweb

If your web server is accessible from the internet it is important that you secure MythWeb with some kind of authentication. This guide will take you through setting up simple password authentication. Please see the Apache [1] for more specifics or more secure methods.

There are several ways to secure MythWeb:

  • Modify the MythWeb .htaccess file to require password authentication
  • Modify the Apache configuration to require password authentication
  • Setup an SSH tunnel for remote access to MythWeb (assuming that you do not open your MythWeb server to the internet except for port-forwarding SSH from your router/firewall)

These instructions assume Fedora Core, with Myth Web installed in the default path /var/www/html/mythweb

MythWeb .htaccess

The simplest option is to edit /var/www/html/mythweb/.htaccess and read the comments there about what to uncomment to secure MythWeb. This option does not require Apache to be restarted, but is slightly less efficient than adding the options to the Apache config.

You may use either AuthType Basic or AuthType digest -- "Basic" is more compatible, "Digest" is more secure. If you use "Basic", you must use htpasswd to create users. If you use "Digest", you must use htdigest to create users.

openSUSE 10.2

Geeko head48.png


These steps are for openSUSE 10.2 The instructions are written using "htpasswd2" instead of "htdigest2" because that is what I got to work. I'm sure you could use "htdigest2", I'm just now sure how. These steps should work fine though.

You will need to install Apache2, PHP5.1 (or preferrably PHP5.2), Mythweb

MythTV openSUSE RPMS will install the mythweb files into /srv/www/htdocs/mythweb


Configure Apache2


In YasT under Network Services->HTTP Server.

Under "Server Modules" make sure you have "env" and "rewrite" modules enabled

Under "Main Hosts" select "Directory /srv/www/htdocs "

Change Options to FollowSymLinks

Change AllowOveride to All

save and exit


Start Apache2 Web Server


YasT->System->System Services

Select apache2 and enable

save and exit

Setup Security

1. create a new password file with htpasswd2

WARNING: the "-c" will wipe out the file if it already exists

/usr/bin/htpasswd2 -c /etc/apache2/conf.d/httpd-passwords userid

You will be prompted to put in a password for the userid

2. create any additional user IDs (no "-c")

/usr/bin/htpasswd2 /etc/apache2/conf.d/httpd-passwords another_userid

3. Find the user:group that apache2 is running as

cat /etc/apache2/uid.conf

The file will probably look similar to this:

User wwwrun
Group www

4. Change the ownership of the password file (change "wwwrun:www" to match the "User:Group" from the previous step)

chown wwwrun:www /etc/apache2/conf.d/httpd-passwords

5. If the .htaccess exists, which it probably does if you have mythweb installed, back it up. This is just in case you mess it up and it need to start over.

cd /srv/www/htdocs/mythweb/
cp ./.htaccess ./.htaccess.orig

6. Open .htaccess for modification with vi - or whatever floats your boat

vi ./.htaccess

7. The following lines should be present but commented. Remove the "#" from the start of each line, modify them to fit your setup, and save the file. Changes are immediate. Pay special attention to the bolded lines

AuthType           Basic
AuthName           "MythTV"
AuthUserFile       /etc/apache2/conf.d/httpd-passwords
Require            valid-user
BrowserMatch       "MSIE"      AuthDigestEnableQueryStringHack=On

Save the file and authentication should begin immediately.

8. If you don't want to bother with authentication when you are on the same network, add the following lines and authentication will be bypassed (assuming 192.168.1.0 is your local network).

Allow from 192.168.1.
Satisfy any

If you aren't sure what your network is, if you are using a router purchased from a store, you could probably get away with specifying "Allow from 192.168.". This would also cover you if you move your box from one location to another using a different third octet in the IP. With this in place, though, you should not be prompted now for authentication while on the local network.

UPDATE: I'm not 100% sure that this last step works. I tested from a remote site and was able to access MythWeb without being prompted for a password. The remote site also used the 192.168.1 network range. After removing the last two entries above, it prompted right away.

NOTE: I had the same problem with the last step not working, but after a lot of digging it turned out that there were conflicting authentication configurations in the main apache config file and in the sites-enabled/default files. These are the settings which worked for me.

<Directory>
  AuthType Basic
  AuthName "MythTV"
  AuthUserFile /etc/apache2/conf.d/httpd-passwords
  Require valid-user
  Order deny,allow
  Deny from all
  Allow from 192.168.0 127
  Satisfy Any
</Directory>

Possible Problems:

/var/log/apache2/error_log show "RewriteEngine" messages

[Mon Jul 23 21:35:19 2007] [alert] [client 192.168.0.187] /srv/www/htdocs/mythweb/.htaccess:\
Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server\  
configuration

Install the apache2 rewrite module

# a2enmod rewrite
# /etc/init.d/apache2 force-reload

Other Linux Flavors

Create a Password File

You will need to create an htdigest password file -- a suggested location is /etc/httpd/conf, but it should be a location that gets backed up regularly.

htdigest -c /etc/httpd/conf/httpd-passwords MythTV MYUSER1

Create additional users as needed:

htdigest /etc/httpd/conf/httpd-passwords MythTV MYUSER2

Please make sure you DO NOT use the -c after the initial user, as this will overwrite the file and start from scratch.

Modify ownership of the file to match the user and group Apache is running as -- try

grep -A 2 ^User /etc/httpd/conf/httpd.conf 
chown apache.apache /etc/httpd/conf/httpd-passwords
chmod 640 /etc/httpd/conf/httpd-passwords
Modify .htaccess
nano /var/www/html/mythweb/.htaccess

The following lines should be present but commented. Remove the "#" from the start of each line, modify them to fit your setup, and save the file. Changes are immediate.

    AuthType           Digest
    AuthName           "MythTV"
    AuthUserFile       /etc/httpd/conf/httpd-passwords
    Require            valid-user
    BrowserMatch       "MSIE"      AuthDigestEnableQueryStringHack=On

Adding the following optional lines will enforce authentication from anywhere outside your local network (assuming 192.168.1.0 is your local network):

    Allow from 192.168.1.
    Satisfy any

Authentication should begin working immediately.

Apache Configuration

This method is slightly more efficient than the .htaccess method, but is complicated by the fact that you must restart Apache and mis-configuring the Apache configuration file will keep Apache from restarting.

Apache password file

We will start with creating an Apache password file. I put this in /etc/httpd/conf, as I back up this directory every night to one of my other systems.

htpasswd -c /etc/httpd/conf/httpd-passwords MYUSER1

Create additional users as needed:

htpasswd /etc/httpd/conf/httpd-passwords MYUSER2

Please make sure you DO NOT use the -c after the initial user, as this will overwrite the file and start from scratch.

Modify ownership of the file as follows:

chown apache.apache /etc/httpd/conf/httpd-passwords
chmod 640 /etc/httpd/conf/httpd-passwords

Editing Apache Config

Now edit /etc/httpd/conf/httpd.conf, and add the following section:

<Directory "/var/www/html/mythweb">
    Options Indexes FollowSymLinks
    AuthType Basic
    AuthName "MythTV"
    AuthUserFile /etc/httpd/conf/httpd-passwords
    require user MYUSER1 MYUSER2 MYUSER3
    Order allow,deny
    Allow from all
</Directory>

Modify the password file location and required users per your needs.

If you have created a link from your music storage area to /var/www/html/mythweb/music, you can add the following to separately secure web access to this:

#MythWeb music configuration
<Directory "/var/www/html/mythweb/music">
    Options Indexes FollowSymLinks
    AuthType Basic
    AuthName "MythTV-Music"
    AuthUserFile /etc/httpd/conf/httpd-passwords
    Require user MYUSER4 MYUSER5
    Order allow,deny
    Allow from all
</Directory>

Again, tailor your password file and users to your needs. You can even use separate password files if you wish!

Securing only the "settings" section

It is also possible to improve security on MythWeb without requiring every user to enter a username and password. Standard users will still be able to do things such as delete recordings, edit video metadata, etc, but you can at least restrict their access to dangerous pages such as the settings section. This is done on Apache by using the "LocationMatch" directive:

<LocationMatch .*/settings>
        AuthType        Digest
        AuthName        "MythTV"
        AuthUserFile    /etc/mythtv/mythweb-digest
        Require         valid-user
        BrowserMatch    "MSIE"  AuthDigestEnableQueryStringHack=On
        Order           Allow,Deny
        Satisfy         Any
</LocationMatch>

It should also be possible to restrict any individual action on Mythweb using the right regular expression in the LocationMatch.

Restart Apache

Now restart Apache, and you're done:

service httpd restart

(this may be different on your distro)

Other options

You can do a lot more with these configuration sections, such as secure by ip address, and more. Please see the Apache docs[2].

Questions: email me at johanreinalda at yahoo dot com. Preferred is an email to Myth Users list, however. Here's the configuration I used to allow users on my LAN to access MythWeb without a password, and require outside users to authenticate via pw

<Directory "/var/www/html/mythweb">
  Options Indexes FollowSymLinks
  AuthType Basic
  AuthName "MythTV"
  AuthUserFile /etc/httpd/conf/httpd-passwords
  Require valid-user
  Order allow,deny
  Allow from 192.168.1.
  Satisfy any
</Directory>

NOTE: I have found that "Allow from 192.168.1." does not work correctly when your webserver is behind a router, as any traffic forwarded over the router will appear to originate from 192.168.1.1 (or whatever your router's IP is). This will cause ANY outside traffic to satisfy the "Any" requirement. -- craftyguy

Troubleshooting

If you install or upgrade MythWeb and your web browser gives you garbage instead of a pretty page

Find the apache/htdocs/mythweb/.htaccess file and comment out (with a # sign) the three lines which begin php_value zlib.. (This note doesn't actually belong here, but I didn't want it to get lost, since I had to rummage in the mailing list to find it again. --Baylink 22:10, 7 October 2006 (UTC))

Mythweb fails to detect wap/wml devices when secured

If MythWeb is secured it will use the logged in username to record the mythweb settings including the template/skin. This is great if you are browsing mythweb from different PCs but will bypass the detection of mobile (wap/wml) devices. A simple workaround is to ensure you setup a different userid to authenticate with from your phone. --Lwoggardner 12:08, 14 October 2006 (UTC)

The user settings are stored in the table mythweb_sessions. To reset the stored session information for a particular user, simply delete the record for that user:

DELETE FROM mythweb_sessions WHERE id = 'user:<username>'

Database connection issues

If you have edited your .htaccess db values to match your mysql.txt file and still cannot connect to database you may have mysql database problems. Try:

GRANT ALL ON mythconverg.* TO mythtv@localhost IDENTIFIED BY 'mythtv'
WITH GRANT OPTION
FLUSH PRIVILEGES;

Streaming Music via Mythweb

If Streaming Music over Mythweb is not working check to confirm that there is a link to your music directory in mythweb/data. If your music is stored in /mythtv/music and your web directory is /var/www/html/mythweb then you would need to add a link like.

ln -s /mythtv/Music /var/www/html/mythweb/data/music

Then confirm that it worked

ll /var/www/html/mythweb/data

MythVideo error on Mythweb

Error:

Could not create a symlink to /content/dvd, the local MythVideo directory for this hostname (hostname).
Please create a symlink to your MythVideo directory at data/video in order to use the video portions of MythWeb.

I could fix this by deliting the symlink /var/www/html/mythweb/data/video with this command "rm /var/www/html/mythweb/data/video". This would allow mythweb to pull up the video page without the artwork. but when i would refreshed it i would get the error. Notes:

My Video Directory: /content/dvd

This is related to permissions in the /content folder. So i did this

chown -R mythtv:apache /content
chmod -R 755 /content


I had the same problem and found out that the symlink was not created properly. If you create a new symlink in the mythweb data folder (www/mythweb/data) to your video folder and video cover folder everything works fine. The error should tell you which file to link to using the following command

ln -s target_file video
ln -s target_file video_covers

where target file is the location of your video and video_cover folders respectively.

Time Stamp is off by an hour

Arizona does not follow daylight savings time. PHP can't read the system timezone causing the Mythweb time to be an hour fast. The following needs to be set in php.ini:
[Date] ; Defines the default timezone used by the date functions
date.timezone = America/Phoenix

If your timezone has daylight saving which moves from year to year, you might experience this problem. This is because PHP does not use the system timezone information but has its own timezone database built in. System timezone information is easily updated (e.g. yum update tzdata) and if your system clock is wrong you probably should. The compiled-in data of PHP is not easily updated and reflects what the developers of PHP thought was correct when it was coded at some time in the past. The times in the MythTV database may be correct even though they show incorrectly in MythWeb. This happened in timezone Australia/Sydney in March/April 2008 when the daylight saving change was moved back by one week - MythWeb times were one hour out for the week and then corrected themselves.

To resolve future issues with daylight savings timezones being altered it may be neccessary to update the php timezone database. The following process was used successfully with Ubuntu 7.10 (Gutsy).

sudo apt-get install php-pear

sudo pecl install timezonedb

Thumbnails are not generated

Check this fix and make sure that

allow_url_fopen = On

in your php.ini.

Alternative Skins

MythWeb uses the concept of skins to give the user the power to edit/change the look and feel. The skins are based on CSS files that can be customized.

Following list of available skins can be install additionally to the default one:

To install the skins, extract them to the mythweb/skins/ directory.

See Also