Use middleware instead of the noscheme workaround in order to make HTTPS work behind a reverse-proxy

This commit is contained in:
Pierre Rudloff 2017-05-14 21:53:57 +02:00
parent f53fc5ebc1
commit fed425fce3
7 changed files with 70 additions and 238 deletions

View file

@ -30,13 +30,14 @@ class ViewFactory
}
$view = new Smarty(__DIR__.'/../templates/');
if (in_array('https', $request->getHeader('X-Forwarded-Proto'))) {
$request = $request->withUri($request->getUri()->withScheme('https')->withPort(443));
}
$smartyPlugins = new SmartyPlugins($container['router'], $request->getUri());
$view->registerPlugin('function', 'path_for', [$smartyPlugins, 'pathFor']);
$view->registerPlugin('function', 'base_url', [$smartyPlugins, 'baseUrl']);
$view->registerPlugin('modifier', 'noscheme', 'Smarty_Modifier_noscheme');
return $view;
}
}

View file

@ -11,7 +11,6 @@
"symfony/yaml": "~3.2.0",
"symfony/process": "~3.2.0",
"ptachoire/process-builder-chain": "~1.2.0",
"rudloff/smarty-plugin-noscheme": "~0.1.0",
"guzzlehttp/guzzle": "~6.2.0",
"rudloff/rtmpdump-bin": "~2.3",
"aura/session": "~2.1.0"
@ -80,6 +79,6 @@
}
},
"scripts": {
"compile": "composer install --dev"
"compile": "composer install --ignore-platform-reqs"
}
}

288
composer.lock generated
View file

@ -4,7 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "6fda75dec4d72b9620ca68697278dc7e",
"hash": "0a4bd158955df2e3f5ea89714ba9e740",
"content-hash": "cb0e773496b6f26caf1c8591f23488f5",
"packages": [
{
"name": "aura/session",
@ -66,7 +67,7 @@
"session",
"sessions"
],
"time": "2016-10-03T20:28:32+00:00"
"time": "2016-10-03 20:28:32"
},
{
"name": "container-interop/container-interop",
@ -97,7 +98,7 @@
],
"description": "Promoting the interoperability of container objects (DIC, SL, etc.)",
"homepage": "https://github.com/container-interop/container-interop",
"time": "2017-02-14T19:40:03+00:00"
"time": "2017-02-14 19:40:03"
},
{
"name": "guzzlehttp/guzzle",
@ -159,7 +160,7 @@
"rest",
"web service"
],
"time": "2017-02-28T22:50:30+00:00"
"time": "2017-02-28 22:50:30"
},
{
"name": "guzzlehttp/promises",
@ -210,7 +211,7 @@
"keywords": [
"promise"
],
"time": "2016-12-20T10:07:11+00:00"
"time": "2016-12-20 10:07:11"
},
{
"name": "guzzlehttp/psr7",
@ -275,137 +276,7 @@
"uri",
"url"
],
"time": "2017-03-20T17:10:46+00:00"
},
{
"name": "jeremykendall/php-domain-parser",
"version": "3.0.0",
"source": {
"type": "git",
"url": "https://github.com/jeremykendall/php-domain-parser.git",
"reference": "896e7e70f02bd4fd77190052799bc61e4d779672"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/jeremykendall/php-domain-parser/zipball/896e7e70f02bd4fd77190052799bc61e4d779672",
"reference": "896e7e70f02bd4fd77190052799bc61e4d779672",
"shasum": ""
},
"require": {
"ext-curl": "*",
"ext-intl": "*",
"ext-mbstring": "*",
"php": ">=5.3.0"
},
"require-dev": {
"jeremykendall/debug-die": "0.0.1.*",
"mikey179/vfsstream": "~1.4",
"phpunit/phpunit": "~4.4"
},
"bin": [
"bin/parse",
"bin/update-psl"
],
"type": "library",
"autoload": {
"psr-0": {
"Pdp\\": "src/"
},
"files": [
"src/pdp-parse-url.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jeremy Kendall",
"homepage": "http://about.me/jeremykendall",
"role": "Developer"
},
{
"name": "Contributors",
"homepage": "https://github.com/jeremykendall/php-domain-parser/graphs/contributors"
}
],
"description": "Public Suffix List based URL parsing implemented in PHP.",
"homepage": "https://github.com/jeremykendall/php-domain-parser",
"keywords": [
"Public Suffix List",
"domain parsing",
"url parsing"
],
"time": "2015-03-30T12:49:45+00:00"
},
{
"name": "league/uri",
"version": "4.2.2",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/uri.git",
"reference": "a2e73bad7e60c3bc61b649680fb8b46876e342e3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/uri/zipball/a2e73bad7e60c3bc61b649680fb8b46876e342e3",
"reference": "a2e73bad7e60c3bc61b649680fb8b46876e342e3",
"shasum": ""
},
"require": {
"ext-fileinfo": "*",
"ext-intl": "*",
"ext-mbstring": "*",
"jeremykendall/php-domain-parser": "^3.0",
"php": ">=5.5.9",
"psr/http-message": "^1.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^1.9",
"phpunit/phpunit": "^4.0",
"zendframework/zend-diactoros": "^1.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.2.x-dev"
}
},
"autoload": {
"psr-4": {
"League\\Uri\\": "src"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ignace Nyamagana Butera",
"email": "nyamsprod@gmail.com",
"homepage": "https://nyamsprod.com"
}
],
"description": "URI manipulation library",
"homepage": "http://uri.thephpleague.com",
"keywords": [
"data-uri",
"ftp",
"http",
"https",
"parse_url",
"psr-7",
"rfc3986",
"uri",
"url",
"ws"
],
"time": "2016-12-12T11:36:42+00:00"
"time": "2017-03-20 17:10:46"
},
{
"name": "mathmarques/smarty-view",
@ -455,7 +326,7 @@
"template",
"view"
],
"time": "2016-08-25T19:04:49+00:00"
"time": "2016-08-25 19:04:49"
},
{
"name": "nikic/fast-route",
@ -498,7 +369,7 @@
"router",
"routing"
],
"time": "2017-01-19T11:35:12+00:00"
"time": "2017-01-19 11:35:12"
},
{
"name": "pimple/pimple",
@ -544,7 +415,7 @@
"container",
"dependency injection"
],
"time": "2015-09-11T15:10:35+00:00"
"time": "2015-09-11 15:10:35"
},
{
"name": "psr/container",
@ -593,7 +464,7 @@
"container-interop",
"psr"
],
"time": "2017-02-14T16:28:37+00:00"
"time": "2017-02-14 16:28:37"
},
{
"name": "psr/http-message",
@ -643,7 +514,7 @@
"request",
"response"
],
"time": "2016-08-06T14:39:51+00:00"
"time": "2016-08-06 14:39:51"
},
{
"name": "ptachoire/process-builder-chain",
@ -679,7 +550,7 @@
}
],
"description": "Add ability to chain symfony processes",
"time": "2016-04-10T08:33:20+00:00"
"time": "2016-04-10 08:33:20"
},
{
"name": "rudloff/rtmpdump-bin",
@ -707,48 +578,7 @@
"GPL-2.0"
],
"description": "rtmpdump binary for Linux 64 bit",
"time": "2016-04-12T19:17:32+00:00"
},
{
"name": "rudloff/smarty-plugin-noscheme",
"version": "0.1.2",
"source": {
"type": "git",
"url": "https://github.com/Rudloff/smarty-plugin-noscheme.git",
"reference": "927e6a43cb30f864a34edf454dcb0f60f0bbf093"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Rudloff/smarty-plugin-noscheme/zipball/927e6a43cb30f864a34edf454dcb0f60f0bbf093",
"reference": "927e6a43cb30f864a34edf454dcb0f60f0bbf093",
"shasum": ""
},
"require": {
"league/uri": "~4.2.2"
},
"require-dev": {
"symfony/var-dumper": "~3.0.1"
},
"type": "library",
"autoload": {
"files": [
"modifier.noscheme.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-3.0"
],
"authors": [
{
"name": "Pierre Rudloff",
"email": "contact@rudloff.pro",
"homepage": "https://rudloff.pro/",
"role": "Developer"
}
],
"description": "Smarty modifier that removes the scheme in URLs",
"time": "2017-04-15T18:14:00+00:00"
"time": "2016-04-12 19:17:32"
},
{
"name": "slim/slim",
@ -819,7 +649,7 @@
"micro",
"router"
],
"time": "2017-03-19T17:55:20+00:00"
"time": "2017-03-19 17:55:20"
},
{
"name": "smarty/smarty",
@ -872,20 +702,20 @@
"keywords": [
"templating"
],
"time": "2016-12-14T21:57:25+00:00"
"time": "2016-12-14 21:57:25"
},
{
"name": "symfony/process",
"version": "v3.2.7",
"version": "v3.2.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "57fdaa55827ae14d617550ebe71a820f0a5e2282"
"reference": "999c2cf5061e627e6cd551dc9ebf90dd1d11d9f0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/57fdaa55827ae14d617550ebe71a820f0a5e2282",
"reference": "57fdaa55827ae14d617550ebe71a820f0a5e2282",
"url": "https://api.github.com/repos/symfony/process/zipball/999c2cf5061e627e6cd551dc9ebf90dd1d11d9f0",
"reference": "999c2cf5061e627e6cd551dc9ebf90dd1d11d9f0",
"shasum": ""
},
"require": {
@ -921,20 +751,20 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2017-03-27T18:07:02+00:00"
"time": "2017-04-12 14:13:17"
},
{
"name": "symfony/yaml",
"version": "v3.2.7",
"version": "v3.2.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "62b4cdb99d52cb1ff253c465eb1532a80cebb621"
"reference": "acec26fcf7f3031e094e910b94b002fa53d4e4d6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/62b4cdb99d52cb1ff253c465eb1532a80cebb621",
"reference": "62b4cdb99d52cb1ff253c465eb1532a80cebb621",
"url": "https://api.github.com/repos/symfony/yaml/zipball/acec26fcf7f3031e094e910b94b002fa53d4e4d6",
"reference": "acec26fcf7f3031e094e910b94b002fa53d4e4d6",
"shasum": ""
},
"require": {
@ -976,7 +806,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2017-03-20T09:45:15+00:00"
"time": "2017-05-01 14:55:58"
}
],
"packages-dev": [
@ -1032,7 +862,7 @@
"constructor",
"instantiate"
],
"time": "2015-06-14T21:17:01+00:00"
"time": "2015-06-14 21:17:01"
},
{
"name": "ffmpeg/ffmpeg",
@ -1090,7 +920,7 @@
"nginx",
"php"
],
"time": "2017-03-27T23:33:27+00:00"
"time": "2017-03-27 23:33:27"
},
{
"name": "myclabs/deep-copy",
@ -1132,7 +962,7 @@
"object",
"object graph"
],
"time": "2017-04-12T18:52:22+00:00"
"time": "2017-04-12 18:52:22"
},
{
"name": "phpdocumentor/reflection-common",
@ -1186,7 +1016,7 @@
"reflection",
"static analysis"
],
"time": "2015-12-27T11:43:31+00:00"
"time": "2015-12-27 11:43:31"
},
{
"name": "phpdocumentor/reflection-docblock",
@ -1231,7 +1061,7 @@
}
],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
"time": "2016-09-30T07:12:33+00:00"
"time": "2016-09-30 07:12:33"
},
{
"name": "phpdocumentor/type-resolver",
@ -1278,7 +1108,7 @@
"email": "me@mikevanriel.com"
}
],
"time": "2016-11-25T06:54:22+00:00"
"time": "2016-11-25 06:54:22"
},
{
"name": "phpspec/prophecy",
@ -1341,7 +1171,7 @@
"spy",
"stub"
],
"time": "2017-03-02T20:05:34+00:00"
"time": "2017-03-02 20:05:34"
},
{
"name": "phpunit/php-code-coverage",
@ -1404,7 +1234,7 @@
"testing",
"xunit"
],
"time": "2017-04-02T07:44:40+00:00"
"time": "2017-04-02 07:44:40"
},
{
"name": "phpunit/php-file-iterator",
@ -1451,7 +1281,7 @@
"filesystem",
"iterator"
],
"time": "2016-10-03T07:40:28+00:00"
"time": "2016-10-03 07:40:28"
},
{
"name": "phpunit/php-text-template",
@ -1492,7 +1322,7 @@
"keywords": [
"template"
],
"time": "2015-06-21T13:50:34+00:00"
"time": "2015-06-21 13:50:34"
},
{
"name": "phpunit/php-timer",
@ -1541,7 +1371,7 @@
"keywords": [
"timer"
],
"time": "2017-02-26T11:10:40+00:00"
"time": "2017-02-26 11:10:40"
},
{
"name": "phpunit/php-token-stream",
@ -1590,7 +1420,7 @@
"keywords": [
"tokenizer"
],
"time": "2017-02-27T10:12:30+00:00"
"time": "2017-02-27 10:12:30"
},
{
"name": "phpunit/phpunit",
@ -1672,7 +1502,7 @@
"testing",
"xunit"
],
"time": "2017-04-03T02:22:27+00:00"
"time": "2017-04-03 02:22:27"
},
{
"name": "phpunit/phpunit-mock-objects",
@ -1731,7 +1561,7 @@
"mock",
"xunit"
],
"time": "2016-12-08T20:27:08+00:00"
"time": "2016-12-08 20:27:08"
},
{
"name": "rg3/youtube-dl",
@ -1787,7 +1617,7 @@
],
"description": "Looks up which function or method a line of code belongs to",
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
"time": "2017-03-04T06:30:41+00:00"
"time": "2017-03-04 06:30:41"
},
{
"name": "sebastian/comparator",
@ -1851,7 +1681,7 @@
"compare",
"equality"
],
"time": "2017-01-29T09:50:25+00:00"
"time": "2017-01-29 09:50:25"
},
{
"name": "sebastian/diff",
@ -1903,7 +1733,7 @@
"keywords": [
"diff"
],
"time": "2015-12-08T07:14:41+00:00"
"time": "2015-12-08 07:14:41"
},
{
"name": "sebastian/environment",
@ -1953,7 +1783,7 @@
"environment",
"hhvm"
],
"time": "2016-11-26T07:53:53+00:00"
"time": "2016-11-26 07:53:53"
},
{
"name": "sebastian/exporter",
@ -2020,7 +1850,7 @@
"export",
"exporter"
],
"time": "2016-11-19T08:54:04+00:00"
"time": "2016-11-19 08:54:04"
},
{
"name": "sebastian/global-state",
@ -2071,7 +1901,7 @@
"keywords": [
"global state"
],
"time": "2015-10-12T03:26:01+00:00"
"time": "2015-10-12 03:26:01"
},
{
"name": "sebastian/object-enumerator",
@ -2117,7 +1947,7 @@
],
"description": "Traverses array structures and object graphs to enumerate all referenced objects",
"homepage": "https://github.com/sebastianbergmann/object-enumerator/",
"time": "2017-02-18T15:18:39+00:00"
"time": "2017-02-18 15:18:39"
},
{
"name": "sebastian/recursion-context",
@ -2170,7 +2000,7 @@
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"time": "2016-11-19T07:33:16+00:00"
"time": "2016-11-19 07:33:16"
},
{
"name": "sebastian/resource-operations",
@ -2212,7 +2042,7 @@
],
"description": "Provides a list of PHP built-in functions that operate on resources",
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
"time": "2015-07-28T20:34:47+00:00"
"time": "2015-07-28 20:34:47"
},
{
"name": "sebastian/version",
@ -2255,7 +2085,7 @@
],
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version",
"time": "2016-10-03T07:35:21+00:00"
"time": "2016-10-03 07:35:21"
},
{
"name": "squizlabs/php_codesniffer",
@ -2333,7 +2163,7 @@
"phpcs",
"standards"
],
"time": "2017-03-01T22:17:45+00:00"
"time": "2017-03-01 22:17:45"
},
{
"name": "symfony/polyfill-mbstring",
@ -2392,20 +2222,20 @@
"portable",
"shim"
],
"time": "2016-11-14T01:06:16+00:00"
"time": "2016-11-14 01:06:16"
},
{
"name": "symfony/var-dumper",
"version": "v3.2.7",
"version": "v3.2.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
"reference": "81dce20f69a8b40427e1f4e6462178df87cafc03"
"reference": "fa47963ac7979ddbd42b2d646d1b056bddbf7bb8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/81dce20f69a8b40427e1f4e6462178df87cafc03",
"reference": "81dce20f69a8b40427e1f4e6462178df87cafc03",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/fa47963ac7979ddbd42b2d646d1b056bddbf7bb8",
"reference": "fa47963ac7979ddbd42b2d646d1b056bddbf7bb8",
"shasum": ""
},
"require": {
@ -2416,9 +2246,11 @@
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0"
},
"require-dev": {
"ext-iconv": "*",
"twig/twig": "~1.20|~2.0"
},
"suggest": {
"ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).",
"ext-symfony_debug": ""
},
"type": "library",
@ -2458,7 +2290,7 @@
"debug",
"dump"
],
"time": "2017-03-12T16:07:05+00:00"
"time": "2017-05-01 14:55:58"
},
{
"name": "webmozart/assert",
@ -2508,7 +2340,7 @@
"check",
"validate"
],
"time": "2016-11-23T20:04:58+00:00"
"time": "2016-11-23 20:04:58"
}
],
"aliases": [],

View file

@ -16,6 +16,6 @@
Based on <a href="http://rg3.github.io/youtube-dl/">youtube-dl</a>
</div>
</footer>
<script src="{base_url|noscheme}/dist/main.js"></script>
<script src="{base_url}/dist/main.js"></script>
</body>
</html>

View file

@ -8,10 +8,10 @@
<meta name="twitter:description" content="{$description|escape}" />
<meta property="og:description" content="{$description|escape}" />
{/if}
<link rel="stylesheet" href="{base_url|noscheme}/dist/main.css" />
<link rel="stylesheet" href="{base_url}/dist/main.css" />
<title>AllTube Download{if isset($title)} - {$title|escape}{/if}</title>
<link rel="canonical" href="{$canonical}" />
<link rel="icon" href="{base_url|noscheme}/img/favicon.png" />
<link rel="icon" href="{base_url}/img/favicon.png" />
<meta property="og:title" content="AllTube Download{if isset($title)} - {$title|escape}{/if}" />
<meta property="og:image" content="{base_url}/img/logo.png" />
<meta name="twitter:card" content="summary" />

View file

@ -1,4 +1,4 @@
<h1 class="logobis">
<a class="logocompatible" href="{base_url|noscheme}">
AllTube Download<span class="logocompatiblemask"><img src="{base_url|noscheme}/img/logocompatiblemask.png" width="447" height="107" alt="" /></span>
<a class="logocompatible" href="{base_url}">
AllTube Download<span class="logocompatiblemask"><img src="{base_url}/img/logocompatiblemask.png" width="447" height="107" alt="" /></span>
</a></h1>

View file

@ -1,7 +1,7 @@
{include file='inc/head.tpl'}
{include file='inc/header.tpl'}
<div class="main">
<div><img class="logo" src="{base_url|noscheme}/img/logo.png"
<div><img class="logo" src="{base_url}/img/logo.png"
alt="AllTube Download" width="328" height="284"></div>
<form action="{path_for name="video"}">
<label class="labelurl" for="url">