Fix #1427 - webui: Added reverse proxy support.
This includes a next webroot command line argument (using -W) and some minor mods to the core HTTP/WebUI code to support this. Most of the mods are pretty trivial and hopefully nothing will break too badly.
This commit is contained in:
parent
b624851dde
commit
dd379084c0
5 changed files with 34 additions and 6 deletions
14
src/http.c
14
src/http.c
|
@ -608,8 +608,18 @@ http_path_add(const char *path, void *opaque, http_callback_t *callback,
|
|||
{
|
||||
http_path_t *hp = malloc(sizeof(http_path_t));
|
||||
|
||||
hp->hp_len = strlen(path);
|
||||
hp->hp_path = strdup(path);
|
||||
if (tvheadend_webroot) {
|
||||
char *tmp; const char *pre = "";
|
||||
size_t len = strlen(tvheadend_webroot) + strlen(path) + 1;
|
||||
if (*tvheadend_webroot != '/') {
|
||||
len++;
|
||||
pre = "/";
|
||||
}
|
||||
hp->hp_path = tmp = malloc(len);
|
||||
sprintf(tmp, "%s%s%s", pre, tvheadend_webroot, path);
|
||||
} else
|
||||
hp->hp_path = strdup(path);
|
||||
hp->hp_len = strlen(hp->hp_path);
|
||||
hp->hp_opaque = opaque;
|
||||
hp->hp_callback = callback;
|
||||
hp->hp_accessmask = accessmask;
|
||||
|
|
|
@ -77,6 +77,7 @@ int webui_port;
|
|||
int htsp_port;
|
||||
int htsp_port_extra;
|
||||
char *tvheadend_cwd;
|
||||
const char *tvheadend_webroot;
|
||||
|
||||
const char *tvheadend_capabilities[] = {
|
||||
#if ENABLE_CWC
|
||||
|
@ -202,6 +203,7 @@ usage(const char *argv0)
|
|||
printf(" -s Log debug to syslog\n");
|
||||
printf(" -w <portnumber> WebUI access port [default 9981]\n");
|
||||
printf(" -e <portnumber> HTSP access port [default 9982]\n");
|
||||
printf(" -W <path> WebUI context path [default /]\n");
|
||||
printf("\n");
|
||||
printf("Development options\n");
|
||||
printf("\n");
|
||||
|
@ -297,7 +299,7 @@ main(int argc, char **argv)
|
|||
// make sure the timezone is set
|
||||
tzset();
|
||||
|
||||
while((c = getopt(argc, argv, "Aa:fp:u:g:c:Chdr:j:sw:e:E:R:")) != -1) {
|
||||
while((c = getopt(argc, argv, "Aa:fp:u:g:c:Chdr:j:sw:e:E:R:W:")) != -1) {
|
||||
switch(c) {
|
||||
case 'a':
|
||||
adapter_mask = 0x0;
|
||||
|
@ -366,6 +368,9 @@ main(int argc, char **argv)
|
|||
case 'j':
|
||||
join_transport = optarg;
|
||||
break;
|
||||
case 'W':
|
||||
tvheadend_webroot = optarg;
|
||||
break;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
extern const char *tvheadend_version;
|
||||
extern char *tvheadend_cwd;
|
||||
extern const char *tvheadend_capabilities[];
|
||||
extern const char *tvheadend_webroot;
|
||||
|
||||
#define PTS_UNSET INT64_C(0x8000000000000000)
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ tvheadend.help = function(title, pagename) {
|
|||
* General capabilities
|
||||
*/
|
||||
Ext.Ajax.request({
|
||||
url: '/capabilities',
|
||||
url: 'capabilities',
|
||||
success: function(d)
|
||||
{
|
||||
if (d && d.responseText)
|
||||
|
|
|
@ -74,13 +74,24 @@ static int
|
|||
page_root(http_connection_t *hc, const char *remain, void *opaque)
|
||||
{
|
||||
if(is_client_simple(hc)) {
|
||||
http_redirect(hc, "/simple.html");
|
||||
http_redirect(hc, "simple.html");
|
||||
} else {
|
||||
http_redirect(hc, "/extjs.html");
|
||||
http_redirect(hc, "extjs.html");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
page_root2(http_connection_t *hc, const char *remain, void *opaque)
|
||||
{
|
||||
if (!tvheadend_webroot) return 1;
|
||||
char *tmp = malloc(strlen(tvheadend_webroot) + 2);
|
||||
sprintf(tmp, "%s/", tvheadend_webroot);
|
||||
http_redirect(hc, tmp);
|
||||
free(tmp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static download of a file from the filesystem
|
||||
*/
|
||||
|
@ -922,6 +933,7 @@ int page_statedump(http_connection_t *hc, const char *remain, void *opaque);
|
|||
void
|
||||
webui_init(void)
|
||||
{
|
||||
http_path_add("", NULL, page_root2, ACCESS_WEB_INTERFACE);
|
||||
http_path_add("/", NULL, page_root, ACCESS_WEB_INTERFACE);
|
||||
|
||||
http_path_add("/dvrfile", NULL, page_dvrfile, ACCESS_WEB_INTERFACE);
|
||||
|
|
Loading…
Add table
Reference in a new issue