nginxconfig.io/public/templates/conf/sites-available/example.com.conf.html

239 lines
8.0 KiB
HTML
Raw Normal View History

2018-03-09 22:27:39 +00:00
server {<!--
2018-02-27 07:47:27 +00:00
2018-03-09 22:27:39 +00:00
✘ HTTPS || ✘ forceHTTPS --><span ng-if="!isHTTPS() || !isForceHTTPS()">
listen {{ data.ipv4 !== '*' ? data.ipv4 + ':' : '' }}80;<!--
2018-04-21 13:47:37 +00:00
✔ IPv6 --><span ng-if="isIPv6()">
2018-03-09 22:27:39 +00:00
listen [{{ data.ipv6 }}]:80;</span></span><!--
✔ HTTPS --><span ng-if="isHTTPS()">
listen {{ data.ipv4 !== '*' ? data.ipv4 + ':' : '' }}443 ssl{{ isHTTP2() ? ' http2' : '' }};<!--
2018-04-21 13:47:37 +00:00
✔ IPv6 --><span ng-if="isIPv6()">
2018-03-09 22:27:39 +00:00
listen [{{ data.ipv6 }}]:443 ssl{{ isHTTP2() ? ' http2' : '' }};</span></span>
2018-02-18 13:02:11 +00:00
server_name {{ isWWW() ? 'www.' : '' }}{{ domain() }};<!--
✔ PHP --><span ng-if="isPHP()">
2018-02-24 22:39:33 +00:00
set $base {{ data.path ? data.path : '/var/www/' + domain() }};
2018-02-18 13:02:11 +00:00
root $base{{ data.document_root }};</span><!--
✘ PHP --><span ng-if="!isPHP()">
2018-04-21 13:47:37 +00:00
root /var/www/{{ domain() }}{{ data.document_root }};</span><!--
2018-02-27 07:47:27 +00:00
2018-02-18 13:02:11 +00:00
✔ HTTPS --><span ng-if="isHTTPS()">
2018-02-22 23:20:21 +00:00
# SSL
2018-02-18 13:02:11 +00:00
ssl_certificate {{ sslCertificate() }};
ssl_certificate_key {{ sslCertificateKey() }};<!--
✔ Let's Encrypt --><span ng-if="isCertLetsEncrypt()">
2018-02-22 23:20:21 +00:00
ssl_trusted_certificate /etc/letsencrypt/live/{{ domain() }}/fullchain.pem;</span></span><!--
2018-02-18 13:02:11 +00:00
✔ access log domain || error log domain --><span ng-if="isAccessLogDomain() || isErrorLogDomain()">
# logging<!--
✔ access log domain --><span ng-if="isAccessLogDomain()">
access_log {{ accessLogDomainPath() }};</span><!--
✔ error log domain --><span ng-if="isErrorLogDomain()">
error_log {{ errorLogDomainPath() }};</span></span><!--
✔ index.php --><span ng-if="isIndexPHP()">
# index.php
index index.php;</span><!--
2018-08-20 14:04:34 +00:00
✔ Fallback HTML || ✔ Fallback PHP --><span ng-if="(isFallbackHTML() || isFallbackPHP()) && (!isProxy() || data.proxy_path !== '/')">
2018-02-18 13:02:11 +00:00
2018-06-11 22:41:57 +00:00
# {{ isFallbackHTML() ? 'index.html' : ( isFallbackPHP() ? 'index.php' : '' ) }} fallback
2018-02-18 13:02:11 +00:00
location / {
2018-06-11 22:41:57 +00:00
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><!--
2018-12-02 20:36:18 +00:00
✔ Python --><span ng-if="isPython()">
# Python
location / {<!--
✔ modularized --><span ng-if="isModularized()">
include nginxconfig.io/python_uwsgi.conf;</span><!--
✔ unified --><span ng-if="isUnified()">
<!-- --> <ng-include ng-include-tabs="3" src="'templates/conf/nginxconfig.io/python_uwsgi.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></ng-include></span>
}</span><!--
2018-08-20 14:04:34 +00:00
✔ Reverse proxy --><span ng-if="isProxy()">
# reverse proxy
location {{ data.proxy_path }} {
proxy_pass {{ data.proxy_pass }};<!--
✔ modularized --><span ng-if="isModularized()">
include nginxconfig.io/proxy.conf;</span><!--
✔ unified --><span ng-if="isUnified()">
<!-- --> <ng-include ng-include-tabs="3" src="'templates/conf/nginxconfig.io/proxy.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></ng-include></span>
}</span><!--
2018-06-11 22:41:57 +00:00
✔ PHP --><span ng-if="isPHP()">
# handle .php
2018-12-18 22:26:57 +00:00
location ~ {{ isLegacyPHPRouting() ? '[^/]\\.php(/|$)' : '\\.php$' }} {<!--
2018-06-11 22:41:57 +00:00
✔ modularized || ✔ WordPress --><span ng-if="isModularized() || isWordPress()">
2018-08-19 21:17:07 +00:00
include nginxconfig.io/php_fastcgi.conf;</span><!--
2018-06-11 22:41:57 +00:00
✔ unified && ✘ WordPress --><span ng-if="isUnified() && !isWordPress()">
2018-08-19 21:17:07 +00:00
<ng-include ng-include-tabs="{{ isUnified() ? 3 : 1 }}" src="'templates/conf/nginxconfig.io/php_fastcgi.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></ng-include></span>
2018-02-18 13:02:11 +00:00
}</span><!--
✔ unified --><span ng-if="isModularized()">
</span><!--
✔ modularized --><span ng-if="isModularized()">
2018-08-19 21:17:07 +00:00
include nginxconfig.io/general.conf;</span><!--
2018-02-18 13:02:11 +00:00
✔ modularized && ✔ WordPress --><span ng-if="isModularized() && isWordPress()">
2018-08-19 21:17:07 +00:00
include nginxconfig.io/wordpress.conf;</span><!--
2018-02-18 13:02:11 +00:00
2018-07-26 13:29:19 +00:00
✔ modularized && ✔ Drupal --><span ng-if="isModularized() && isDrupal()">
2018-08-19 21:17:07 +00:00
include nginxconfig.io/drupal.conf;</span><!--
2018-07-26 13:29:19 +00:00
2018-12-02 19:28:18 +00:00
✔ modularized && ✔ Magento --><span ng-if="isModularized() && isMagento()">
include nginxconfig.io/magento.conf;</span><!--
2018-02-18 13:02:11 +00:00
✔ unified --><span ng-if="isUnified()">
2018-08-19 21:17:07 +00:00
<!-- --><ng-include ng-include-tabs="2" src="'templates/conf/nginxconfig.io/general.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></ng-include></span><!--
2018-02-18 13:02:11 +00:00
✔ unified && ✔ WordPress --><span ng-if="isUnified() && isWordPress()">
2018-08-19 21:17:07 +00:00
<!-- --><ng-include ng-include-tabs="2" src="'templates/conf/nginxconfig.io/wordpress.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></ng-include></span><!--
2018-07-26 11:24:00 +00:00
✔ unified && ✔ Drupal --><span ng-if="isUnified() && isDrupal()">
2018-12-02 19:28:18 +00:00
<!-- --><ng-include ng-include-tabs="2" src="'templates/conf/nginxconfig.io/drupal.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></ng-include></span><!--
✔ unified && ✔ Magento --><span ng-if="isUnified() && isMagento()">
<!-- --><ng-include ng-include-tabs="2" src="'templates/conf/nginxconfig.io/magento.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></ng-include></span>
2018-02-18 13:02:11 +00:00
}<!--
✔ CDN --><span ng-if="isCDN()">
# CDN
server {
2018-02-27 07:47:27 +00:00
listen {{ data.ipv4 !== '*' ? data.ipv4 + ':' : '' }}{{ isHTTPS() ? '443 ssl' : '80' }}{{ isHTTP2() ? ' http2' : '' }};<!--
✔ IPv6 --><span ng-if="isIPv6()">
listen [{{ data.ipv6 }}]:{{ isHTTPS() ? '443 ssl' : '80' }}{{ isHTTP2() ? ' http2' : '' }};</span>
2018-02-18 13:02:11 +00:00
server_name cdn.{{ domain() }};
root /var/www/{{ domain() }}{{ data.document_root }};<span ng-if="!isAccessLog()">
access_log off;</span><!--
✔ HTTPS --><span ng-if="isHTTPS()">
2018-02-22 23:20:21 +00:00
# SSL
2018-02-18 13:02:11 +00:00
ssl_certificate {{ sslCertificate() }};
ssl_certificate_key {{ sslCertificateKey() }};<!--
✔ Let's Encrypt --><span ng-if="isCertLetsEncrypt()">
2018-02-22 23:20:21 +00:00
ssl_trusted_certificate /etc/letsencrypt/live/{{ domain() }}/fullchain.pem;</span></span>
2018-02-18 13:02:11 +00:00
# disable access_log
access_log off;<!--
✔ Gzip --><span ng-if="isGzip()">
# gzip
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types {{ gzipTypes }};</span>
# allow safe files
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;
}
# deny everything else
location / {
deny all;
}
2018-03-09 22:38:32 +00:00
}</span><!--
2018-02-18 13:02:11 +00:00
2018-03-09 22:38:32 +00:00
✔ redirect --><span ng-if="isRedirect()">
2018-02-18 13:02:11 +00:00
# {{ isWWW() ? 'non-www, ' : '' }}subdomains redirect
server {
2018-02-27 07:47:27 +00:00
listen {{ data.ipv4 !== '*' ? data.ipv4 + ':' : '' }}{{ isHTTPS() ? '443 ssl' : '80' }}{{ isHTTP2() ? ' http2' : '' }};<!--
✔ IPv6 --><span ng-if="isIPv6()">
listen [{{ data.ipv6 }}]:{{ isHTTPS() ? '443 ssl' : '80' }}{{ isHTTP2() ? ' http2' : '' }};</span>
2018-02-18 13:02:11 +00:00
2018-02-22 22:45:49 +00:00
server_name {{ isWWW() ? ('.' + domain()) : ('*.' + domain()) }};<!--
2018-02-18 13:02:11 +00:00
✔ HTTPS --><span ng-if="isHTTPS()">
2018-02-22 23:20:21 +00:00
# SSL
ssl_certificate {{ sslCertificate() }};
ssl_certificate_key {{ sslCertificateKey() }};<!--
2018-02-18 13:02:11 +00:00
✔ Let's Encrypt --><span ng-if="isCertLetsEncrypt()">
2018-02-22 23:20:21 +00:00
ssl_trusted_certificate /etc/letsencrypt/live/{{ domain() }}/fullchain.pem;</span></span>
2018-02-18 13:02:11 +00:00
return 301 http{{ isHTTPS() ? 's' : '' }}://{{ isWWW() ? 'www.' : '' }}{{ domain() }}$request_uri;
2018-02-18 13:02:11 +00:00
}</span><!--
2018-03-09 22:27:39 +00:00
✔ forceHTTPS --><span ng-if="isForceHTTPS()">
2018-02-18 13:02:11 +00:00
# HTTP redirect
server {
2018-02-27 07:47:27 +00:00
listen {{ data.ipv4 !== '*' ? data.ipv4 + ':' : '' }}80;<!--
✔ IPv6 --><span ng-if="isIPv6()">
listen [{{ data.ipv6 }}]:80;</span>
2018-02-18 13:02:11 +00:00
2018-02-22 23:20:21 +00:00
server_name .{{ domain() }};<!--
2018-02-18 13:02:11 +00:00
✔ modularized && ✔ Let's Encrypt --><span ng-if="isModularized() && isCertLetsEncrypt()">
2018-02-22 23:20:21 +00:00
2018-08-19 21:17:07 +00:00
include nginxconfig.io/letsencrypt.conf;</span><!--
2018-02-22 23:20:21 +00:00
✔ unified && ✔ Let's Encrypt --><span ng-if="isUnified() && isCertLetsEncrypt()">
2018-02-22 23:20:21 +00:00
2018-08-19 21:17:07 +00:00
<ng-include ng-include-tabs="2" src="'templates/conf/nginxconfig.io/letsencrypt.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></ng-include></span><!--
2018-02-22 23:20:21 +00:00
✔ Let's Encrypt --><span ng-if="isCertLetsEncrypt()">
2018-02-22 23:20:21 +00:00
location / {
return 301 https://{{ isWWW() ? 'www.' : '' }}{{ domain() }}$request_uri;
}</span><!--
✘ Let's Encrypt --><span ng-if="!isCertLetsEncrypt()">
2018-02-22 23:20:21 +00:00
return 301 https://{{ isWWW() ? 'www.' : '' }}{{ domain() }}$request_uri;</span>
2018-02-18 13:02:11 +00:00
}</span>