MythTV / mythtv

The official MythTV repository
https://www.mythtv.org
GNU General Public License v2.0
707 stars 346 forks source link

MythWeb - protocol relative URL in the HTML - easier to use SSL with a reverse proxy like nginx #846

Open SaveFerrisVote4Pedro opened 9 months ago

SaveFerrisVote4Pedro commented 9 months ago

A few code changes in MythWeb will change the URLs to protocol relative URLs. This makes it much easier to put MythWeb behind a reverse proxy (like nginx) and add the security of SSL certificates.

In a rendered page of MythWeb, the output includes links written like this

<link rel="stylesheet" type="text/css" href="http://my_myth_tv_server/mythweb/skins/default/style.css">

This breaks behind a nginx reverse proxy (which I use to give myself secure access using SSL), so my MythWeb page looks like this:

https://imgur.com/a/lQqR4Cp

They should have the http: removed, so they look like this in the HTML:

<link rel="stylesheet" type="text/css" href="//my_myth_tv_server/mythweb/skins/default/style.css">

That is there should be no http:// in the URL, it should just be //

This would mean that the generated HTML will render correctly regardless of whether the MythWeb is hosted on a http or https webserver.

All that needs to be changed is this line in /usr/share/mythtv/mythweb/includes/defines.php

$root_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';

Becomes

$root_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? '//' : '//';

Obviously there's a more elegant way of doing this, but I'm not a php expert. I figured this out with a bit of trial and error.

My version of MythTV

/mythbuntu/33/ubuntu jammy/main amd64 mythweb all 2:33.1+fixes.202401131706.512d723c83~ubuntu22.04.1

It is a simple fix, it won't break MythWeb for anyone, but it will help me not having to go in and edit defines.php everytime MythWeb is updated 😉

bennettpeter commented 9 months ago

MythTV version 34 has a new web app that has all of the function of mythweb at http://backend:6544. You can try that now on the master version of mythbackend and let me know if any change is needed to support the reverse proxy.

SaveFerrisVote4Pedro commented 9 months ago

Quick reply Peter! Does the v34 look similar to this on v33?

Screenshot 2024-01-19 184924

I don't mind this, but I like a direct URL to TV listings etc

Not just staying on http://192.168.1.234:6544/# no matter where you navigate,

MythWeb updates URLs (eg., from https://my_myth_tv_server/mythweb/tv/list and https://my_myth_tv_server/mythweb/tv/recorded) which I prefer

Call me old fashioned! 😎

bennettpeter commented 9 months ago

The V34 app is completely rewritten. In V34 the program guide URL is http://backend:6544/dashboard/program-guide. Screenshot_2024-01-19_09-08-28