mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Better reverse proxy support
Added "base path override" config option that makes all links and redirects work with your reverse proxy. Fixed post config update reload to work properly. Make redirects and ajax calls use relative pathing.
This commit is contained in:
@@ -19,6 +19,7 @@ using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
@@ -32,7 +33,8 @@ namespace Jackett.Services
|
||||
void ReserveUrls(bool doInstall = true);
|
||||
ServerConfig Config { get; }
|
||||
void SaveConfig();
|
||||
Uri ConvertToProxyLink(Uri link, string serverUrl, string indexerId, string action = "dl", string file = "t.torrent");
|
||||
Uri ConvertToProxyLink(Uri link, string serverUrl, string indexerId, string action = "dl", string file = "t.torrent");
|
||||
string BasePath();
|
||||
}
|
||||
|
||||
public class ServerService : IServerService
|
||||
@@ -77,6 +79,23 @@ namespace Jackett.Services
|
||||
return new Uri(proxyLink);
|
||||
}
|
||||
|
||||
public string BasePath()
|
||||
{
|
||||
if (config.BasePathOverride == null || config.BasePathOverride == "") {
|
||||
return "/";
|
||||
}
|
||||
var path = config.BasePathOverride;
|
||||
if (!path.EndsWith("/"))
|
||||
{
|
||||
path = path + "/";
|
||||
}
|
||||
if (!path.StartsWith("/"))
|
||||
{
|
||||
path = "/" + path;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
private void LoadConfig()
|
||||
{
|
||||
// Load config
|
||||
@@ -139,6 +158,7 @@ namespace Jackett.Services
|
||||
logger.Info("Starting web server at " + config.GetListenAddresses()[0]);
|
||||
var startOptions = new StartOptions();
|
||||
config.GetListenAddresses().ToList().ForEach(u => startOptions.Urls.Add(u));
|
||||
Startup.BasePath = BasePath();
|
||||
_server = WebApp.Start<Startup>(startOptions);
|
||||
logger.Debug("Web server started");
|
||||
updater.StartUpdateChecker();
|
||||
|
Reference in New Issue
Block a user