cdn support, regex fixes
parent
db257d1f68
commit
6560a2990b
|
@ -3,6 +3,9 @@
|
|||
angular
|
||||
.module('NginxConfigIoApp', [])
|
||||
.controller('NginxConfigIoController', function NginxConfigIoController($scope, $timeout) {
|
||||
/////////////////////
|
||||
// SCOPE VARIABLES //
|
||||
/////////////////////
|
||||
$scope.data = {
|
||||
domain: 'example.com',
|
||||
path: '/var/www/example.com',
|
||||
|
@ -10,6 +13,7 @@
|
|||
https: false,
|
||||
http2: true,
|
||||
email: 'hello@example.com',
|
||||
cdn: true,
|
||||
non_www: true,
|
||||
php: '7.2',
|
||||
index_html: false,
|
||||
|
@ -28,13 +32,29 @@
|
|||
limit_req: false,
|
||||
|
||||
expires: {
|
||||
css_js: '7d',
|
||||
media: '7d',
|
||||
assets: '7d',
|
||||
fonts: '7d',
|
||||
svg: '7d',
|
||||
font: '7d',
|
||||
media: '7d',
|
||||
docs: '7d',
|
||||
},
|
||||
};
|
||||
|
||||
$scope.extensions = {
|
||||
assets: 'css(\\.map)?|js(\\.map)?',
|
||||
fonts: 'ttf|ttc|otf|eot|woff|woff2',
|
||||
svg: 'svgz?',
|
||||
images: 'jpe?g|png|gif|ico|cur|heic|webp|tiff?',
|
||||
audio: 'mp3|m4a|aac|ogg|midi?|wav',
|
||||
video: 'mp4|mov|webm|mpe?g|avi|ogv|flv|wmv',
|
||||
docs: 'pdf|docx?|xlsx?|pptx?'
|
||||
};
|
||||
|
||||
|
||||
|
||||
/////////////////////
|
||||
// SCOPE FUNCTIONS //
|
||||
/////////////////////
|
||||
$scope.refreshHighlighting = function() {
|
||||
document.querySelectorAll('main .file .code.source').forEach(function(code) {
|
||||
$timeout(function(code) {
|
||||
|
@ -46,9 +66,12 @@
|
|||
});
|
||||
};
|
||||
|
||||
$scope.$watch('data', function(data) {
|
||||
$scope.refreshHighlighting();
|
||||
}, true);
|
||||
|
||||
|
||||
//////////////////
|
||||
// SCOPE EVENTS //
|
||||
//////////////////
|
||||
$scope.$watch('data', $scope.refreshHighlighting, true);
|
||||
});
|
||||
|
||||
})();
|
||||
|
|
|
@ -49,9 +49,15 @@
|
|||
</label>
|
||||
</div>
|
||||
<div class="form-group" ng-if="data.https">
|
||||
<label class="form-label">E-mail</label>
|
||||
<input type="text" class="form-control form-control-sm" ng-model="data.email">
|
||||
</div>
|
||||
<label class="form-label">E-mail</label>
|
||||
<input type="text" class="form-control form-control-sm" ng-model="data.email">
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="cdn" ng-model="data.cdn">
|
||||
<label class="form-check-label" for="cdn">
|
||||
<span class="info">CDN</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="non_www" ng-model="data.non_www">
|
||||
<label class="form-check-label" for="non_www">
|
||||
|
@ -173,8 +179,8 @@
|
|||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="form-group">
|
||||
<label class="form-label"><span class="info">css/js <code>expires</code></span></label>
|
||||
<input type="text" class="form-control form-control-sm" ng-model="data.expires.css_js">
|
||||
<label class="form-label"><span class="info">assets <code>expires</code></span></label>
|
||||
<input type="text" class="form-control form-control-sm" ng-model="data.expires.assets">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label"><span class="info">media <code>expires</code></span></label>
|
||||
|
@ -185,8 +191,8 @@
|
|||
<input type="text" class="form-control form-control-sm" ng-model="data.expires.svg">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label"><span class="info">font <code>expires</code></span></label>
|
||||
<input type="text" class="form-control form-control-sm" ng-model="data.expires.font">
|
||||
<label class="form-label"><span class="info">fonts <code>expires</code></span></label>
|
||||
<input type="text" class="form-control form-control-sm" ng-model="data.expires.fonts">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -8,31 +8,31 @@ add_header Cache-Control "no-transform" always;
|
|||
# . files
|
||||
location ~ /\.(?!well-known).* {
|
||||
deny all;
|
||||
}<span ng-if="data.expires.css_js !== '' && data.expires.css_js !== data.expires.media">
|
||||
}<span ng-if="data.expires.assets !== '' && data.expires.assets !== data.expires.media">
|
||||
|
||||
# css/js
|
||||
location ~* \.(css|js)$ {
|
||||
expires {{ data.expires.css_js }};<span ng-if="data.access_log !== ''">
|
||||
# assets
|
||||
location ~* \.(?:{{ extensions.assets }})$ {
|
||||
expires {{ data.expires.assets }};<span ng-if="data.access_log !== ''">
|
||||
access_log off;</span>
|
||||
}</span><span ng-if="data.expires.media !== ''">
|
||||
|
||||
# {{ data.expires.css_js !== '' && data.expires.css_js === data.expires.media ? 'css/js, ' : '' }}media
|
||||
location ~* \.({{ data.expires.css_js !== '' && data.expires.css_js === data.expires.media ? 'css|js|' : '' }}jpe?g|gif|png|heic|ico|cur|mp4|mov|ogg|ogv|webm|htc)$ {
|
||||
# {{ data.expires.assets !== '' && data.expires.assets === data.expires.media ? 'assets, ' : '' }}media
|
||||
location ~* \.(?:{{ data.expires.assets !== '' && data.expires.assets === data.expires.media ? extensions.assets + '|' : '' }}{{ extensions.images }}|{{ extensions.audio }}|{{ extensions.video }})$ {
|
||||
expires {{ data.expires.media }};<span ng-if="data.access_log !== ''">
|
||||
access_log off;</span>
|
||||
}</span><span ng-if="data.expires.svg !== '' && data.expires.svg !== data.expires.font">
|
||||
}</span><span ng-if="data.expires.svg !== '' && data.expires.svg !== data.expires.fonts">
|
||||
|
||||
# svg
|
||||
location ~* \.svg$ {
|
||||
location ~* \.{{ extensions.svg }}$ {
|
||||
add_header Access-Control-Allow-Origin "*";
|
||||
expires {{ data.expires.svg }};<span ng-if="data.access_log !== ''">
|
||||
access_log off;</span>
|
||||
}</span><span ng-if="data.expires.font !== ''">
|
||||
}</span><span ng-if="data.expires.fonts !== ''">
|
||||
|
||||
# {{ data.expires.svg !== '' && data.expires.svg === data.expires.font ? 'svg, ' : '' }}fonts
|
||||
location ~* \.({{ data.expires.svg !== '' && data.expires.svg === data.expires.font ? 'svg|' : '' }}ttf|ttc|otf|eot|woff|woff2)$ {
|
||||
# {{ data.expires.svg !== '' && data.expires.svg === data.expires.fonts ? 'svg, ' : '' }}fonts
|
||||
location ~* \.(?:{{ data.expires.svg !== '' && data.expires.svg === data.expires.fonts ? extensions.svg + '|' : '' }}{{ extensions.fonts }})$ {
|
||||
add_header Access-Control-Allow-Origin "*";
|
||||
expires {{ data.expires.font }};<span ng-if="data.access_log !== ''">
|
||||
expires {{ data.expires.fonts }};<span ng-if="data.access_log !== ''">
|
||||
access_log off;</span>
|
||||
}</span>
|
||||
<span ng-if="data.gzip">
|
||||
|
|
|
@ -4,22 +4,22 @@ location = /wp-includes/js/tinymce/wp-tinymce.php {
|
|||
}
|
||||
|
||||
# wp-content, wp-includes php files
|
||||
location ~* ^/(wp-content|wp-includes)/.*\.php$ {
|
||||
location ~* ^/(?:wp-content|wp-includes)/.*\.php$ {
|
||||
deny all;
|
||||
}
|
||||
|
||||
# wp-content/uploads nasty stuff
|
||||
location ~* ^/wp-content/uploads/.*\.(html|htm|shtml|php|js|swf|css)$ {
|
||||
location ~* ^/wp-content/uploads/.*\.(?:s?html?|php|js|swf)$ {
|
||||
deny all;
|
||||
}
|
||||
|
||||
# wp-content/plugins nasty stuff
|
||||
location ~* ^/wp-content/plugins/.*\.(?!jpe?g|gif|png|svg|heic|js|css) {
|
||||
location ~* ^/wp-content/plugins/.*\.(?!{{ extensions.assets }}|{{ extensions.fonts }}|{{ extensions.svg }}|{{ extensions.images }}|{{ extensions.audio }}|{{ extensions.video }}|{{ extensions.docs }}) {
|
||||
deny all;
|
||||
}
|
||||
|
||||
# WordPress stuff
|
||||
location ~* ^/(xmlrpc\.php|wp-config\.php|wp-config-sample\.php|wp-comments-post\.php|readme\.html|license\.txt)$ {
|
||||
location ~* ^/(?:xmlrpc\.php|wp-config\.php|wp-config-sample\.php|wp-comments-post\.php|readme\.html|license\.txt)$ {
|
||||
deny all;
|
||||
}<span ng-if="data.limit_req">
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
<span ng-if="data.https"># certbot certonly --non-interactive --text --email {{ data.email }} --agree-tos --force-renew --webroot --webroot-path /var/www/_letsencrypt --domain {{ data.domain }} --domain www.{{ data.domain }}
|
||||
<span ng-if="data.https"># certbot certonly --non-interactive --text --email {{ data.email }} --agree-tos --force-renew --webroot --webroot-path /var/www/_letsencrypt --domain {{ data.domain }} --domain www.{{ data.domain }}{{ data.cdn ? ' --domain cdn.' + data.domain : '' }}
|
||||
server {
|
||||
listen 443 ssl{{ data.http2 ? ' http2' : '' }};
|
||||
listen [::]:443 ssl{{ data.http2 ? ' http2' : '' }};
|
||||
|
||||
server_name {{ !data.non_www ? 'www.' : '' }}{{ data.domain }};
|
||||
server_name {{ !data.non_www ? 'www.' : '' }}{{ data.domain }};<span ng-if="data.php !== 'off'">
|
||||
set $base /var/www/{{ data.domain }};
|
||||
root $base/{{ data.document_root }};
|
||||
root $base{{ data.document_root }};</span><span ng-if="data.php === 'off'">
|
||||
root /var/www/{{ data.domain }}{{ data.document_root }};</span>
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/{{ data.domain }}/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/{{ data.domain }}/privkey.pem;
|
||||
|
@ -25,9 +26,36 @@ server {
|
|||
<ng-include src="'templates/_letsencrypt.conf.html'" onload="refreshHighlighting()"></ng-include>
|
||||
|
||||
include _ssl.conf;</span>
|
||||
}
|
||||
}<span ng-if="data.cdn">
|
||||
|
||||
# https {{ !data.non_www ? 'domain, ' : '' }}subdomains redirect
|
||||
# CDN
|
||||
server {
|
||||
listen 443 ssl{{ data.http2 ? ' http2' : '' }};
|
||||
listen [::]:443 ssl{{ data.http2 ? ' http2' : '' }};
|
||||
|
||||
server_name cdn.{{ data.domain }};
|
||||
root /var/www/{{ data.domain }}{{ data.document_root }};<span ng-if="data.access_log !== ''">
|
||||
|
||||
access_log off;</span>
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/{{ data.domain }}/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/{{ data.domain }}/privkey.pem;
|
||||
ssl_trusted_certificate /etc/letsencrypt/live/{{ data.domain }}/fullchain.pem;
|
||||
|
||||
include _ssl.conf;
|
||||
|
||||
location ~* \.(?:{{ extensions.assets }}|{{ extensions.fonts }}|{{ extensions.svg }}|{{ extensions.images }}|{{ extensions.audio }}|{{ extensions.video }}|{{ extensions.docs }})$ {
|
||||
add_header Access-Control-Allow-Origin "*";
|
||||
add_header Cache-Control "public";
|
||||
expires 30d;
|
||||
}
|
||||
|
||||
location / {
|
||||
deny all
|
||||
}
|
||||
}</span>
|
||||
|
||||
# HTTPS {{ !data.non_www ? 'domain, ' : '' }}subdomains redirect
|
||||
server {
|
||||
listen 443 ssl{{ data.http2 ? ' http2' : '' }};
|
||||
listen [::]:443 ssl{{ data.http2 ? ' http2' : '' }};
|
||||
|
@ -43,10 +71,10 @@ server {
|
|||
return 301 https://{{ !data.non_www ? 'www.' : '' }}{{ data.domain }}$request_uri;
|
||||
}
|
||||
|
||||
# http redirect
|
||||
# HTTP redirect
|
||||
server {
|
||||
listen [::]:80;
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
server_name {{ data.domain }} *.{{ data.domain }};
|
||||
<span ng-if="data.file_structure === 'separated'">
|
||||
|
@ -55,12 +83,13 @@ server {
|
|||
|
||||
return 301 https://{{ !data.non_www ? 'www.' : '' }}{{ data.domain }}$request_uri;
|
||||
}</span><span ng-if="!data.https">server {
|
||||
listen [::]:80;
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
server_name {{ !data.non_www ? 'www.' : '' }}{{ data.domain }};
|
||||
server_name {{ !data.non_www ? 'www.' : '' }}{{ data.domain }};<span ng-if="data.php !== 'off'">
|
||||
set $base /var/www/{{ data.domain }};
|
||||
root $base/{{ data.document_root }};
|
||||
root $base{{ data.document_root }};</span><span ng-if="data.php === 'off'">
|
||||
root /var/www/{{ data.domain }}{{ data.document_root }};</span>
|
||||
<span ng-if="data.file_structure === 'separated'">
|
||||
include _general.conf;<span ng-if="data.php !== 'off' && data.wordpress">
|
||||
include _wordpress.conf;</span><span ng-if="data.php !== 'off'">
|
||||
|
@ -70,7 +99,28 @@ server {
|
|||
<ng-include src="'templates/_wordpress.conf.html'" onload="refreshHighlighting()"></ng-include></span><span ng-if="data.php !== 'off'">
|
||||
|
||||
<ng-include src="'templates/_php.conf.html'" onload="refreshHighlighting()"></ng-include></span></span>
|
||||
}
|
||||
}<span ng-if="data.cdn">
|
||||
|
||||
# CDN
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
server_name cdn.{{ data.domain }};
|
||||
root /var/www/{{ data.domain }}{{ data.document_root }};<span ng-if="data.access_log !== ''">
|
||||
|
||||
access_log off;</span>
|
||||
|
||||
location ~* \.(?:{{ extensions.assets }}|{{ extensions.fonts }}|{{ extensions.svg }}|{{ extensions.images }}|{{ extensions.audio }}|{{ extensions.video }}|{{ extensions.docs }})$ {
|
||||
add_header Access-Control-Allow-Origin "*";
|
||||
add_header Cache-Control "public";
|
||||
expires 30d;
|
||||
}
|
||||
|
||||
location / {
|
||||
deny all
|
||||
}
|
||||
}</span>
|
||||
|
||||
# {{ !data.non_www ? 'domain, ' : '' }}subdomains redirect
|
||||
server {
|
||||
|
|
Loading…
Reference in New Issue