fallback refactor

pull/23/head
Szekeres Bálint 2018-06-12 00:41:57 +02:00
parent 3712ab8045
commit 11260d7ea5
5 changed files with 55 additions and 61 deletions

View File

@ -49,7 +49,9 @@
cdn: false,
index: 'index.php',
fallback: true,
fallback_html: false,
fallback_php: true,
fallback_php_path: '/api/',
php: '7.2',
wordpress: false,
@ -341,16 +343,20 @@
return $scope.isWWW() && $scope.data.cdn;
};
$scope.isIndexHtml = function() {
return $scope.data.index === 'index.html';
$scope.isIndexHTML = function() {
return $scope.data.index === 'index.html' || !$scope.isPHP();
};
$scope.isIndexPhp = function() {
$scope.isIndexPHP = function() {
return $scope.isPHP() && $scope.data.index === 'index.php';
};
$scope.isFallback = function() {
return $scope.data.fallback && (!$scope.isIndexPhp() || $scope.isPHP);
$scope.isFallbackHTML = function() {
return $scope.data.fallback_html;
};
$scope.isFallbackPHP = function() {
return $scope.data.fallback_php && $scope.isPHP();
};
$scope.isPHP = function() {

View File

@ -235,7 +235,7 @@
</div>
<div class="card">
<div class="card-body">
<label class="form-label"><code tooltips tooltip-template="Defines the file that will be used as an index, optionally configures fallback of unhandled requests.">index</code></label>
<label class="form-label"><code tooltips tooltip-template="Defines the file that will be used as an index.">index</code></label>
<div class="form-subgroup">
<div class="form-check">
<input class="form-check-input" type="radio" id="index.html" ng-model="data.index" value="index.html">
@ -248,11 +248,22 @@
<label class="form-check-label" for="index.php">index.php</label>
</div>
</div>
<div class="form-check mt-2">
<input class="form-check-input" type="checkbox" id="fallback" ng-model="data.fallback">
<label class="form-check-label" for="fallback">
<span tooltips tooltip-template="Fallback of unhandled requests.">fallback <small>({{ isIndexPhp() ? 'index.php' : 'index.html' }})</small></span>
</label>
<label class="form-label mt-3"><span tooltips tooltip-template="Configures fallback routing of unhandled requests.">fallback routing</span></label>
<div class="form-subgroup">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="fallback_html" ng-model="data.fallback_html">
<label class="form-check-label" for="fallback_html">index.html</label>
</div>
<div class="form-check" ng-if="isPHP()">
<input class="form-check-input" type="checkbox" id="fallback_php" ng-model="data.fallback_php">
<label class="form-check-label" for="fallback_php">index.php</label>
</div>
<div class="form-subgroup" ng-if="isFallbackHTML() && isFallbackPHP()">
<div class="form-group pl-1">
<input type="text" class="form-control form-control-sm" ng-model="data.fallback_php_path">
</div>
</div>
</div>
</div>
</div>
@ -389,7 +400,7 @@
<div class="col-md-6 col-lg-7 files">
<div class="row grid">
<div class="grid-sizer col-xl-6"></div>
<div ng-if="(isHTTPS() && (isCertLetsEncrypt() || !isSSLProfileModern())) || isWordPress()" class="grid-item col-xl-12" ng-cloak>
<div ng-if="(isHTTPS() && (isCertLetsEncrypt() || !isSSLProfileModern()))" class="grid-item col-xl-12" ng-cloak>
<div class="commands">
<pre><code class="hljs bash" ng-include="'templates/commands.html?v=COMMIT_HASH'"></code></pre>
</div>
@ -434,16 +445,6 @@
<pre><code class="nginx" ng-include="'templates/conf/_general.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></code></pre>
</div><div id="file-general" class="code highlighted"></div>
</div>
<div class="col-xl-6 grid-item file" ng-if="isPHP() && isModularized()" ng-cloak>
<strong>/etc/nginx/_php.conf</strong>
<button class="btn btn-light btn-clipboard" ngclipboard data-clipboard-target="#file-php" ngclipboard-success="clipboardSuccess('_php.conf')">
<img src="assets/img/clipboard-dark.svg" alt="Copy to clipboard">
</button>
<span class="clipboard-success" ng-if="clipboardCopy === '_php.conf'">Copied!</span>
<div class="code source"data-filename="_php.conf">
<pre><code class="nginx" ng-include="'templates/conf/_php.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></code></pre>
</div><div id="file-php" class="code highlighted"></div>
</div>
<div class="col-xl-6 grid-item file" ng-if="isPHP() && (isModularized() || isWordPress())" ng-cloak>
<strong>/etc/nginx/_php_fastcgi.conf</strong>
<button class="btn btn-light btn-clipboard" ngclipboard data-clipboard-target="#file-php_fastcgi" ngclipboard-success="clipboardSuccess('_php_fastcgi.conf')">

View File

@ -25,15 +25,4 @@
--><span class="hljs-attribute">--agree-tos</span> <!--
--><span class="hljs-attribute">--force-renewal</span><!--
--></span><!--
✔ HTTPS && ✔ WordPress --><span ng-if="isHTTPS() && isWordPress()">
</span><!--
✔ WordPress --><span ng-if="isWordPress()"><!--
--><span class="hljs-comment"># <strong>WordPress</strong>: add to <strong>wp-config.php</strong> <small>(<a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-6389" target="_blank">CVE-2018-6389</a>)</small></span>
<span class="hljs-section">define(<span class="hljs-string">'CONCATENATE_SCRIPTS'</span>, <span class="hljs-literal">false</span>);</span></span>
--></span>

View File

@ -1,14 +0,0 @@
<!--
✔ modularized && ✔ index.php --><span ng-if="isModularized() && isIndexPhp()"># index.php
index index.php;
</span><!--
--># handle .php
location ~ \.php$ {<!--
✔ modularized || ✔ WordPress --><span ng-if="isModularized() || isWordPress()">
include _php_fastcgi.conf;</span><!--
✔ unified && ✘ WordPress --><span ng-if="isUnified() && !isWordPress()">
<ng-include ng-include-tabs="{{ isUnified() ? 3 : 1 }}" src="'templates/conf/_php_fastcgi.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></ng-include></span>
}

View File

@ -21,7 +21,7 @@ server {<!--
✘ PHP --><span ng-if="!isPHP()">
root /var/www/{{ domain() }}{{ data.document_root }};</span><!--
unified &&index.php --><span ng-if="isUnified() && isIndexPhp()">
✔ index.php --><span ng-if="isIndexPHP()">
# index.php
index index.php;</span><!--
@ -35,11 +35,30 @@ server {<!--
✔ Let's Encrypt --><span ng-if="isCertLetsEncrypt()">
ssl_trusted_certificate /etc/letsencrypt/live/{{ domain() }}/fullchain.pem;</span></span><!--
fallback --><span ng-if="isFallback()">
Fallback HTML || ✔ Fallback PHP --><span ng-if="isFallbackHTML() || isFallbackPHP()">
# $uri{{ isFallback() ? (', ' + data.index) : '' }}
# {{ isFallbackHTML() ? 'index.html' : ( isFallbackPHP() ? 'index.php' : '' ) }} fallback
location / {
try_files $uri $uri/ {{ isIndexHtml() ? '/index.html' : '' }}{{ isIndexPhp() ? '/index.php?$query_string' : '' }};
try_files $uri $uri/ {{ isFallbackHTML() ? '/index.html' : ( isFallbackPHP() ? '/index.php?$query_string' : '' ) }};
}</span><!--
✔ Fallback HTML && ✔ Fallback PHP --><span ng-if="isFallbackHTML() && isFallbackPHP()">
# index.php fallback
location ~ ^{{ data.fallback_php_path }} {
try_files $uri $uri/ /index.php?$query_string;
}</span><!--
✔ PHP --><span ng-if="isPHP()">
# handle .php
location ~ \.php$ {<!--
✔ modularized || ✔ WordPress --><span ng-if="isModularized() || isWordPress()">
include _php_fastcgi.conf;</span><!--
✔ unified && ✘ WordPress --><span ng-if="isUnified() && !isWordPress()">
<ng-include ng-include-tabs="{{ isUnified() ? 3 : 1 }}" src="'templates/conf/_php_fastcgi.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></ng-include></span>
}</span><!--
✔ unified --><span ng-if="isModularized()">
@ -53,9 +72,6 @@ server {<!--
✔ modularized && ✔ WordPress --><span ng-if="isModularized() && isWordPress()">
include _wordpress.conf;</span><!--
✔ modularized && ✔ PHP --><span ng-if="isModularized() && isPHP()">
include _php.conf;</span><!--
✔ unified --><span ng-if="isUnified()">
@ -64,11 +80,7 @@ server {<!--
✔ unified && ✔ WordPress --><span ng-if="isUnified() && isWordPress()">
<!-- --><ng-include ng-include-tabs="2" src="'templates/conf/_wordpress.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></ng-include></span><!--
✔ modularized && ✔ PHP --><span ng-if="isUnified() && isPHP()">
<!-- --><ng-include ng-include-tabs="2" src="'templates/conf/_php.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></ng-include></span>
<!-- --><ng-include ng-include-tabs="2" src="'templates/conf/_wordpress.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></ng-include></span>
}<!--