mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Fix better reverse proxy support
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
var basePath = "";
|
var basePath = '';
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$.ajaxSetup({ cache: false });
|
$.ajaxSetup({ cache: false });
|
||||||
@@ -7,7 +7,7 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
bindUIButtons();
|
bindUIButtons();
|
||||||
loadJackettSettings();
|
loadJackettSettings();
|
||||||
reloadIndexers();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function getJackettConfig(callback) {
|
function getJackettConfig(callback) {
|
||||||
@@ -26,6 +26,10 @@ function loadJackettSettings() {
|
|||||||
$("#jackett-port").val(data.config.port);
|
$("#jackett-port").val(data.config.port);
|
||||||
$("#jackett-basepathoverride").val(data.config.basepathoverride);
|
$("#jackett-basepathoverride").val(data.config.basepathoverride);
|
||||||
basePath = data.config.basepathoverride;
|
basePath = data.config.basepathoverride;
|
||||||
|
if (basePath === null || basePath === undefined) {
|
||||||
|
basePath = '';
|
||||||
|
}
|
||||||
|
|
||||||
$("#jackett-savedir").val(data.config.blackholedir);
|
$("#jackett-savedir").val(data.config.blackholedir);
|
||||||
$("#jackett-allowext").attr('checked', data.config.external);
|
$("#jackett-allowext").attr('checked', data.config.external);
|
||||||
$("#jackett-allowupdate").attr('checked', data.config.updatedisabled);
|
$("#jackett-allowupdate").attr('checked', data.config.updatedisabled);
|
||||||
@@ -36,6 +40,8 @@ function loadJackettSettings() {
|
|||||||
if (password != null && password != '') {
|
if (password != null && password != '') {
|
||||||
$("#logoutBtn").show();
|
$("#logoutBtn").show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reloadIndexers();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,8 +62,8 @@ function displayIndexers(items) {
|
|||||||
$('#unconfigured-indexers-template').empty();
|
$('#unconfigured-indexers-template').empty();
|
||||||
for (var i = 0; i < items.length; i++) {
|
for (var i = 0; i < items.length; i++) {
|
||||||
var item = items[i];
|
var item = items[i];
|
||||||
item.torznab_host = resolveUrl("/" + basePath + "/torznab/" + item.id);
|
item.torznab_host = resolveUrl(basePath + "/torznab/" + item.id);
|
||||||
item.potato_host = resolveUrl("/" + basePath + "/potato/" + item.id);
|
item.potato_host = resolveUrl(basePath + "/potato/" + item.id);
|
||||||
if (item.configured)
|
if (item.configured)
|
||||||
$('#indexers').append(indexerTemplate(item));
|
$('#indexers').append(indexerTemplate(item));
|
||||||
else
|
else
|
||||||
|
@@ -86,7 +86,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="input-area">
|
<div class="input-area">
|
||||||
<span class="input-header">Base Path Override: </span>
|
<span class="input-header">Base Path Override: </span>
|
||||||
<input id="jackett-basepathoverride" class="form-control input-right" type="text" value="" placeholder="jackett/">
|
<input id="jackett-basepathoverride" class="form-control input-right" type="text" value="" placeholder="/jackett/">
|
||||||
</div>
|
</div>
|
||||||
<div class="input-area">
|
<div class="input-area">
|
||||||
<span class="input-header">Server port: </span>
|
<span class="input-header">Server port: </span>
|
||||||
|
@@ -1,35 +1,42 @@
|
|||||||
using Jackett.Services;
|
using Jackett.Services;
|
||||||
using Microsoft.Owin;
|
using Microsoft.Owin;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Jackett.Utils
|
namespace Jackett.Utils
|
||||||
{
|
{
|
||||||
public class WebApiRootRedirectMiddleware : OwinMiddleware
|
public class WebApiRootRedirectMiddleware : OwinMiddleware
|
||||||
{
|
{
|
||||||
public WebApiRootRedirectMiddleware(OwinMiddleware next)
|
public WebApiRootRedirectMiddleware(OwinMiddleware next)
|
||||||
: base(next)
|
: base(next)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public async override Task Invoke(IOwinContext context)
|
public async override Task Invoke(IOwinContext context)
|
||||||
{
|
{
|
||||||
var url = context.Request.Uri;
|
var url = context.Request.Uri;
|
||||||
if (string.IsNullOrWhiteSpace(url.AbsolutePath) || url.AbsolutePath == "/")
|
if(context.Request.Path != null && context.Request.Path.HasValue && context.Request.Path.Value.StartsWith(Startup.BasePath))
|
||||||
{
|
{
|
||||||
// 301 is the status code of permanent redirect
|
context.Request.Path = new PathString(context.Request.Path.Value.Substring(Startup.BasePath.Length-1));
|
||||||
context.Response.StatusCode = 301;
|
}
|
||||||
var redir = Startup.BasePath + "Admin/Dashboard";
|
|
||||||
Engine.Logger.Info("redirecting to " + redir);
|
if (string.IsNullOrWhiteSpace(url.AbsolutePath) || url.AbsolutePath == "/")
|
||||||
context.Response.Headers.Set("Location", redir);
|
{
|
||||||
}
|
// 301 is the status code of permanent redirect
|
||||||
else
|
context.Response.StatusCode = 301;
|
||||||
{
|
var redir = Startup.BasePath + "Admin/Dashboard";
|
||||||
await Next.Invoke(context);
|
Engine.Logger.Info("redirecting to " + redir);
|
||||||
}
|
context.Response.Headers.Set("Location", redir);
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
await Next.Invoke(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user