@scandipwa/magento-scripts 1.14.1-alpha.3 → 1.14.1-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/cli.js +28 -1
- package/lib/commands/execute.js +2 -1
- package/lib/config/docker.js +45 -9
- package/lib/config/get-port-config.js +2 -1
- package/lib/config/port-config.js +1 -0
- package/lib/config/templates/magentorc.template +3 -5
- package/lib/config/templates/php.template.ini +6 -4
- package/lib/config/templates/varnish.template.vcl +241 -0
- package/lib/config/versions/magento-2.3.0.js +9 -0
- package/lib/config/versions/magento-2.3.1.js +9 -0
- package/lib/config/versions/magento-2.3.2-p2.js +9 -0
- package/lib/config/versions/magento-2.3.2.js +9 -0
- package/lib/config/versions/magento-2.3.3-p1.js +9 -0
- package/lib/config/versions/magento-2.3.3.js +9 -0
- package/lib/config/versions/magento-2.3.4-p2.js +9 -0
- package/lib/config/versions/magento-2.3.4.js +9 -0
- package/lib/config/versions/magento-2.3.5-p1.js +9 -0
- package/lib/config/versions/magento-2.3.5-p2.js +9 -0
- package/lib/config/versions/magento-2.3.5.js +9 -0
- package/lib/config/versions/magento-2.3.6-p1.js +9 -0
- package/lib/config/versions/magento-2.3.6.js +9 -0
- package/lib/config/versions/magento-2.3.7-p1.js +9 -0
- package/lib/config/versions/magento-2.3.7-p2.js +9 -0
- package/lib/config/versions/magento-2.3.7-p3.js +9 -0
- package/lib/config/versions/magento-2.3.7.js +9 -0
- package/lib/config/versions/magento-2.4.0-p1.js +9 -0
- package/lib/config/versions/magento-2.4.0.js +9 -0
- package/lib/config/versions/magento-2.4.1-p1.js +9 -0
- package/lib/config/versions/magento-2.4.1.js +9 -0
- package/lib/config/versions/magento-2.4.2-p1.js +9 -0
- package/lib/config/versions/magento-2.4.2-p2.js +9 -0
- package/lib/config/versions/magento-2.4.2.js +9 -0
- package/lib/config/versions/magento-2.4.3-p1.js +9 -0
- package/lib/config/versions/magento-2.4.3-p2.js +9 -0
- package/lib/config/versions/magento-2.4.3.js +9 -0
- package/lib/config/versions/magento-2.4.4.js +9 -0
- package/lib/tasks/cli/create-bashrc-config.js +5 -2
- package/lib/tasks/docker/containers.js +10 -8
- package/lib/tasks/docker/volumes.js +4 -4
- package/lib/tasks/file-system/create-nginx-config.js +5 -0
- package/lib/tasks/file-system/create-varnish-config.js +51 -0
- package/lib/tasks/file-system/index.js +3 -1
- package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +1 -1
- package/lib/tasks/magento/setup-magento/disable-2fa.js +4 -12
- package/lib/tasks/magento/setup-magento/disable-full-page-cache.js +20 -0
- package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +14 -16
- package/lib/tasks/magento/setup-magento/migrate-database.js +21 -6
- package/lib/tasks/magento/setup-magento/varnish-config.js +63 -0
- package/lib/tasks/mysql/fix-db.js +2 -2
- package/lib/tasks/php/index.js +1 -1
- package/lib/tasks/php/update-env-php.js +16 -1
- package/lib/tasks/php/update-env.php +54 -12
- package/lib/tasks/requirements/index.js +5 -5
- package/lib/tasks/requirements/php-version.js +3 -1
- package/lib/tasks/status/index.js +1 -1
- package/lib/tasks/theme/link-theme.js +2 -2
- package/lib/tasks/theme/setup-persisted-query.js +3 -3
- package/lib/tasks/theme/setup-themes.js +2 -2
- package/lib/util/config-file-validator.js +11 -1
- package/lib/util/config-php-json.js +19 -0
- package/lib/util/php-task.js +6 -2
- package/lib/util/run-php.js +7 -1
- package/package.json +2 -2
- package/typings/context.d.ts +1 -0
- package/typings/index.d.ts +19 -0
- package/lib/tasks/magento/setup-magento/adjust-magento-configuration.js +0 -27
- package/lib/tasks/magento/setup-magento/disable-page-cache.js +0 -11
package/lib/commands/cli.js
CHANGED
|
@@ -7,6 +7,7 @@ const getProjectConfiguration = require('../config/get-project-configuration');
|
|
|
7
7
|
const localAuthJson = require('../tasks/composer/local-auth-json');
|
|
8
8
|
const checkConfigurationFile = require('../config/check-configuration-file');
|
|
9
9
|
const { installComposer, installPrestissimo } = require('../tasks/composer');
|
|
10
|
+
const ConsoleBlock = require('../util/console-block');
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* @param {import('yargs')} yargs
|
|
@@ -30,13 +31,39 @@ module.exports = (yargs) => {
|
|
|
30
31
|
rendererOptions: { collapse: false, clearOutput: true }
|
|
31
32
|
});
|
|
32
33
|
|
|
34
|
+
let ctx;
|
|
33
35
|
try {
|
|
34
|
-
await tasks.run();
|
|
36
|
+
ctx = await tasks.run();
|
|
35
37
|
} catch (e) {
|
|
36
38
|
logger.error(e.message || e);
|
|
37
39
|
process.exit(1);
|
|
38
40
|
}
|
|
39
41
|
|
|
42
|
+
const block = new ConsoleBlock();
|
|
43
|
+
|
|
44
|
+
block
|
|
45
|
+
.addHeader('Create Magento App CLI')
|
|
46
|
+
.addEmptyLine()
|
|
47
|
+
.addLine(`Available aliases: ${logger.style.command('php')}, ${logger.style.command('magento')}, ${logger.style.command('composer')}`)
|
|
48
|
+
.addLine(`Available shortcuts: magento -> ${logger.style.command('m')}, composer -> ${logger.style.command('c')}`)
|
|
49
|
+
.addEmptyLine();
|
|
50
|
+
|
|
51
|
+
if (ctx.config.overridenConfiguration.configuration.varnish.enabled) {
|
|
52
|
+
block.addLine(`Clear Varnish cache: ${logger.style.command('cvc')}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
block
|
|
56
|
+
.addLine(`Clear Magento cache: ${logger.style.command('m c:c')}`)
|
|
57
|
+
.addLine(`Magento setup upgrade: ${logger.style.command('m se:up')}`)
|
|
58
|
+
.addLine(`Magento DI compile: ${logger.style.command('m s:d:c')}`);
|
|
59
|
+
|
|
60
|
+
block
|
|
61
|
+
.addEmptyLine()
|
|
62
|
+
.addLine(`Clear Composer cache: ${logger.style.command('c cc')}`)
|
|
63
|
+
.addEmptyLine();
|
|
64
|
+
|
|
65
|
+
block.log();
|
|
66
|
+
|
|
40
67
|
return cli();
|
|
41
68
|
});
|
|
42
69
|
};
|
package/lib/commands/execute.js
CHANGED
package/lib/config/docker.js
CHANGED
|
@@ -12,7 +12,8 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
12
12
|
redis,
|
|
13
13
|
mysql,
|
|
14
14
|
elasticsearch,
|
|
15
|
-
mariadb
|
|
15
|
+
mariadb,
|
|
16
|
+
varnish
|
|
16
17
|
} = configuration;
|
|
17
18
|
|
|
18
19
|
const {
|
|
@@ -42,7 +43,6 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
42
43
|
const isLinux = os.platform() === 'linux';
|
|
43
44
|
const isWsl = await getIsWsl();
|
|
44
45
|
const isArm = (await getArch()) === 'arm64';
|
|
45
|
-
const isArmMac = (os.platform() === 'darwin') && isArm;
|
|
46
46
|
|
|
47
47
|
if (!isLinux) {
|
|
48
48
|
/**
|
|
@@ -53,7 +53,7 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
53
53
|
name: `${ prefix }_nginx-data`,
|
|
54
54
|
opts: {
|
|
55
55
|
type: 'nfs',
|
|
56
|
-
device: `${cacheDir
|
|
56
|
+
device: `${ path.join(cacheDir, 'nginx', 'conf.d') }`,
|
|
57
57
|
o: 'bind'
|
|
58
58
|
}
|
|
59
59
|
};
|
|
@@ -69,10 +69,20 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
69
69
|
name: `${ prefix }_setup-data`,
|
|
70
70
|
opts: {
|
|
71
71
|
type: 'nfs',
|
|
72
|
-
device: `${path.join(magentoDir, 'setup')}`,
|
|
72
|
+
device: `${ path.join(magentoDir, 'setup') }`,
|
|
73
73
|
o: 'bind'
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
|
+
|
|
77
|
+
if (varnish.enabled) {
|
|
78
|
+
volumes.varnish = {
|
|
79
|
+
name: `${ prefix }_varnish-vcl-data`,
|
|
80
|
+
opts: {
|
|
81
|
+
type: 'nfs',
|
|
82
|
+
device: `${ path.join(cacheDir, 'varnish', 'default.vcl') }`
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
76
86
|
}
|
|
77
87
|
|
|
78
88
|
const getContainers = (ports = {}) => {
|
|
@@ -80,7 +90,7 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
80
90
|
nginx: {
|
|
81
91
|
_: 'Nginx',
|
|
82
92
|
ports: (!isLinux || isWsl) ? [
|
|
83
|
-
`${isIpAddress(host) ? host : '127.0.0.1'}:${ ports.app }:80`
|
|
93
|
+
`${ isIpAddress(host) ? host : '127.0.0.1' }:${ ports.app }:80`
|
|
84
94
|
] : [],
|
|
85
95
|
healthCheck: {
|
|
86
96
|
cmd: 'service nginx status'
|
|
@@ -126,7 +136,7 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
126
136
|
connectCommand: ['redis-cli']
|
|
127
137
|
},
|
|
128
138
|
mysql: {
|
|
129
|
-
_: !
|
|
139
|
+
_: !isArm ? 'MySQL' : 'MariaDB',
|
|
130
140
|
healthCheck: {
|
|
131
141
|
cmd: 'mysqladmin ping --silent'
|
|
132
142
|
},
|
|
@@ -154,15 +164,15 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
154
164
|
'seccomp=unconfined'
|
|
155
165
|
],
|
|
156
166
|
network: network.name,
|
|
157
|
-
image: !
|
|
158
|
-
imageDetails: !
|
|
167
|
+
image: !isArm ? `mysql:${ mysql.version }` : `mariadb:${ mariadb.version }`,
|
|
168
|
+
imageDetails: !isArm ? {
|
|
159
169
|
name: 'mysql',
|
|
160
170
|
tag: mysql.version
|
|
161
171
|
} : {
|
|
162
172
|
name: 'mariadb',
|
|
163
173
|
tag: mariadb.version
|
|
164
174
|
},
|
|
165
|
-
name: !
|
|
175
|
+
name: !isArm ? `${ prefix }_mysql` : `${ prefix }_mariadb`
|
|
166
176
|
},
|
|
167
177
|
elasticsearch: {
|
|
168
178
|
_: 'ElasticSearch',
|
|
@@ -195,6 +205,32 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
195
205
|
);
|
|
196
206
|
}
|
|
197
207
|
|
|
208
|
+
if (varnish.enabled) {
|
|
209
|
+
dockerConfig.varnish = {
|
|
210
|
+
_: 'Varnish',
|
|
211
|
+
image: `varnish:${ varnish.version }`,
|
|
212
|
+
imageDetails: {
|
|
213
|
+
name: 'varnish',
|
|
214
|
+
tag: varnish.version
|
|
215
|
+
},
|
|
216
|
+
name: `${ prefix }_varnish`,
|
|
217
|
+
mountVolumes: isLinux ? [
|
|
218
|
+
`${ path.join(cacheDir, 'varnish', 'default.vcl') }:/etc/varnish/default.vcl:ro`
|
|
219
|
+
] : [
|
|
220
|
+
`${ volumes.varnish.name }:/etc/varnish/default.vcl`
|
|
221
|
+
],
|
|
222
|
+
env: {
|
|
223
|
+
VARNISH_SIZE: '2G'
|
|
224
|
+
},
|
|
225
|
+
restart: 'on-failure:30',
|
|
226
|
+
network: (!isLinux || isWsl) ? network.name : 'host',
|
|
227
|
+
command: `varnishd -F -a :${ ports.varnish } -t 600 -f /etc/varnish/default.vcl`,
|
|
228
|
+
tmpfs: [
|
|
229
|
+
'/var/lib/varnish:exec'
|
|
230
|
+
]
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
198
234
|
return dockerConfig;
|
|
199
235
|
};
|
|
200
236
|
|
|
@@ -51,7 +51,7 @@ const getAvailablePorts = () => ({
|
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
* @type {import('listr2').ListrTask<import('../../typings/context').ListrContext>}
|
|
54
|
+
* @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
|
|
55
55
|
*/
|
|
56
56
|
const getCachedPorts = () => ({
|
|
57
57
|
title: 'Getting cached ports',
|
|
@@ -65,6 +65,7 @@ const getCachedPorts = () => ({
|
|
|
65
65
|
'utf-8'
|
|
66
66
|
)
|
|
67
67
|
);
|
|
68
|
+
ctx.cachedPorts = { ...ports };
|
|
68
69
|
} else {
|
|
69
70
|
ports = { ...defaultPorts };
|
|
70
71
|
}
|
|
@@ -3,10 +3,8 @@ alias magento="php $PWD/bin/magento"
|
|
|
3
3
|
alias m="magento"
|
|
4
4
|
alias composer="php $PWD/node_modules/.create-magento-app-cache/composer/composer.phar"
|
|
5
5
|
alias c="composer"
|
|
6
|
+
<% if (it.varnishEnabled) { %>
|
|
7
|
+
alias cvc="npm run exec varnish varnishadm ban req.url '~ /' && echo 'Varnish cache cleared!'"
|
|
8
|
+
<% } %>
|
|
6
9
|
|
|
7
10
|
export BASH_SILENCE_DEPRECATION_WARNING=1
|
|
8
|
-
|
|
9
|
-
echo ""
|
|
10
|
-
echo "Available aliases: php, magento, composer"
|
|
11
|
-
echo "Available shortcuts: magento -> m, composer -> c"
|
|
12
|
-
echo ""
|
|
@@ -1812,7 +1812,7 @@ ldap.max_links = -1
|
|
|
1812
1812
|
|
|
1813
1813
|
[opcache]
|
|
1814
1814
|
; Determines if Zend OPCache is enabled
|
|
1815
|
-
|
|
1815
|
+
opcache.enable=1
|
|
1816
1816
|
|
|
1817
1817
|
; Determines if Zend OPCache is enabled for the CLI version of PHP
|
|
1818
1818
|
;opcache.enable_cli=0
|
|
@@ -1838,19 +1838,19 @@ ldap.max_links = -1
|
|
|
1838
1838
|
|
|
1839
1839
|
; When disabled, you must reset the OPcache manually or restart the
|
|
1840
1840
|
; webserver for changes to the filesystem to take effect.
|
|
1841
|
-
|
|
1841
|
+
opcache.validate_timestamps=1
|
|
1842
1842
|
|
|
1843
1843
|
; How often (in seconds) to check file timestamps for changes to the shared
|
|
1844
1844
|
; memory storage allocation. ("1" means validate once per second, but only
|
|
1845
1845
|
; once per request. "0" means always validate)
|
|
1846
|
-
|
|
1846
|
+
opcache.revalidate_freq=2
|
|
1847
1847
|
|
|
1848
1848
|
; Enables or disables file search in include_path optimization
|
|
1849
1849
|
;opcache.revalidate_path=0
|
|
1850
1850
|
|
|
1851
1851
|
; If disabled, all PHPDoc comments are dropped from the code to reduce the
|
|
1852
1852
|
; size of the optimized code.
|
|
1853
|
-
|
|
1853
|
+
opcache.save_comments=1
|
|
1854
1854
|
|
|
1855
1855
|
; If enabled, compilation warnings (including notices and deprecations) will
|
|
1856
1856
|
; be recorded and replayed each time a file is included. Otherwise, compilation
|
|
@@ -2038,3 +2038,5 @@ xdebug.mode=off
|
|
|
2038
2038
|
<% } %>
|
|
2039
2039
|
|
|
2040
2040
|
<% } %>
|
|
2041
|
+
|
|
2042
|
+
apc.enabled=1
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
# VCL version 5.0 is not supported so it should be 4.0 even though actually used Varnish version is 6
|
|
2
|
+
vcl 4.0;
|
|
3
|
+
|
|
4
|
+
import std;
|
|
5
|
+
# The minimal Varnish version is 6.0
|
|
6
|
+
# For SSL offloading, pass the following header in your proxy server or load balancer: 'X-Forwarded-Proto: https'
|
|
7
|
+
|
|
8
|
+
backend default {
|
|
9
|
+
.host = "<%= it.hostMachine %>";
|
|
10
|
+
.port = "<%= it.hostPort %>";
|
|
11
|
+
.first_byte_timeout = 600s;
|
|
12
|
+
.probe = {
|
|
13
|
+
.url = "/health_check.php";
|
|
14
|
+
.timeout = 2s;
|
|
15
|
+
.interval = 5s;
|
|
16
|
+
.window = 10;
|
|
17
|
+
.threshold = 5;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
acl purge {
|
|
22
|
+
"<%= it.hostMachine %>";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
sub vcl_recv {
|
|
26
|
+
if (req.restarts > 0) {
|
|
27
|
+
set req.hash_always_miss = true;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (req.method == "PURGE") {
|
|
31
|
+
if (client.ip !~ purge) {
|
|
32
|
+
return (synth(405, "Method not allowed"));
|
|
33
|
+
}
|
|
34
|
+
# To use the X-Pool header for purging varnish during automated deployments, make sure the X-Pool header
|
|
35
|
+
# has been added to the response in your backend server config. This is used, for example, by the
|
|
36
|
+
# capistrano-magento2 gem for purging old content from varnish during it's deploy routine.
|
|
37
|
+
if (!req.http.X-Magento-Tags-Pattern && !req.http.X-Pool) {
|
|
38
|
+
return (synth(400, "X-Magento-Tags-Pattern or X-Pool header required"));
|
|
39
|
+
}
|
|
40
|
+
if (req.http.X-Magento-Tags-Pattern) {
|
|
41
|
+
ban("obj.http.X-Magento-Tags ~ " + req.http.X-Magento-Tags-Pattern);
|
|
42
|
+
}
|
|
43
|
+
if (req.http.X-Pool) {
|
|
44
|
+
ban("obj.http.X-Pool ~ " + req.http.X-Pool);
|
|
45
|
+
}
|
|
46
|
+
return (synth(200, "Purged"));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (req.method != "GET" &&
|
|
50
|
+
req.method != "HEAD" &&
|
|
51
|
+
req.method != "PUT" &&
|
|
52
|
+
req.method != "POST" &&
|
|
53
|
+
req.method != "TRACE" &&
|
|
54
|
+
req.method != "OPTIONS" &&
|
|
55
|
+
req.method != "DELETE") {
|
|
56
|
+
/* Non-RFC2616 or CONNECT which is weird. */
|
|
57
|
+
return (pipe);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
# We only deal with GET and HEAD by default
|
|
61
|
+
if (req.method != "GET" && req.method != "HEAD") {
|
|
62
|
+
return (pass);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
# Bypass customer, shopping cart, checkout
|
|
66
|
+
if (req.url ~ "/customer" || req.url ~ "/checkout") {
|
|
67
|
+
return (pass);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
# Bypass health check requests
|
|
71
|
+
if (req.url ~ "^/(pub/)?(health_check.php)$") {
|
|
72
|
+
return (pass);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
# Set initial grace period usage status
|
|
76
|
+
set req.http.grace = "none";
|
|
77
|
+
|
|
78
|
+
# normalize url in case of leading HTTP scheme and domain
|
|
79
|
+
set req.url = regsub(req.url, "^http[s]?://", "");
|
|
80
|
+
|
|
81
|
+
# collect all cookies
|
|
82
|
+
std.collect(req.http.Cookie);
|
|
83
|
+
|
|
84
|
+
# Compression filter. See https://www.varnish-cache.org/trac/wiki/FAQ/Compression
|
|
85
|
+
if (req.http.Accept-Encoding) {
|
|
86
|
+
if (req.url ~ "\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$") {
|
|
87
|
+
# No point in compressing these
|
|
88
|
+
unset req.http.Accept-Encoding;
|
|
89
|
+
} elsif (req.http.Accept-Encoding ~ "gzip") {
|
|
90
|
+
set req.http.Accept-Encoding = "gzip";
|
|
91
|
+
} elsif (req.http.Accept-Encoding ~ "deflate" && req.http.user-agent !~ "MSIE") {
|
|
92
|
+
set req.http.Accept-Encoding = "deflate";
|
|
93
|
+
} else {
|
|
94
|
+
# unknown algorithm
|
|
95
|
+
unset req.http.Accept-Encoding;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
# Remove all marketing get parameters to minimize the cache objects
|
|
100
|
+
if (req.url ~ "(\?|&)(gclid|cx|ie|cof|siteurl|zanpid|origin|fbclid|mc_[a-z]+|utm_[a-z]+|_bta_[a-z]+)=") {
|
|
101
|
+
set req.url = regsuball(req.url, "(gclid|cx|ie|cof|siteurl|zanpid|origin|fbclid|mc_[a-z]+|utm_[a-z]+|_bta_[a-z]+)=[-_A-z0-9+()%.]+&?", "");
|
|
102
|
+
set req.url = regsub(req.url, "[?|&]+$", "");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
# Static files caching
|
|
106
|
+
if (req.url ~ "^/(pub/)?(media|static)/") {
|
|
107
|
+
# Static files should not be cached by default
|
|
108
|
+
return (pass);
|
|
109
|
+
|
|
110
|
+
# But if you use a few locales and don't use CDN you can enable caching static files by commenting previous line (#return (pass);) and uncommenting next 3 lines
|
|
111
|
+
#unset req.http.Https;
|
|
112
|
+
#unset req.http.X-Forwarded-Proto;
|
|
113
|
+
#unset req.http.Cookie;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
# Authenticated GraphQL requests should not be cached by default
|
|
117
|
+
if (req.url ~ "/graphql" && req.http.Authorization ~ "^Bearer") {
|
|
118
|
+
return (pass);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return (hash);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
sub vcl_hash {
|
|
125
|
+
if (req.http.cookie ~ "X-Magento-Vary=") {
|
|
126
|
+
hash_data(regsub(req.http.cookie, "^.*?X-Magento-Vary=([^;]+);*.*$", "\1"));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
# To make sure http users don't see ssl warning
|
|
130
|
+
if (req.http.X-Forwarded-Proto) {
|
|
131
|
+
hash_data(req.http.X-Forwarded-Proto);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (req.url ~ "/graphql") {
|
|
135
|
+
call process_graphql_headers;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
sub process_graphql_headers {
|
|
140
|
+
if (req.http.Store) {
|
|
141
|
+
hash_data(req.http.Store);
|
|
142
|
+
}
|
|
143
|
+
if (req.http.Content-Currency) {
|
|
144
|
+
hash_data(req.http.Content-Currency);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
sub vcl_backend_response {
|
|
149
|
+
|
|
150
|
+
set beresp.grace = 3d;
|
|
151
|
+
|
|
152
|
+
if (beresp.http.content-type ~ "text") {
|
|
153
|
+
set beresp.do_esi = true;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (bereq.url ~ "\.js$" || beresp.http.content-type ~ "text") {
|
|
157
|
+
set beresp.do_gzip = true;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (beresp.http.X-Magento-Debug) {
|
|
161
|
+
set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
# cache only successfully responses and 404s
|
|
165
|
+
if (beresp.status != 200 && beresp.status != 404) {
|
|
166
|
+
set beresp.ttl = 0s;
|
|
167
|
+
set beresp.uncacheable = true;
|
|
168
|
+
return (deliver);
|
|
169
|
+
} elsif (beresp.http.Cache-Control ~ "private") {
|
|
170
|
+
set beresp.uncacheable = true;
|
|
171
|
+
set beresp.ttl = 86400s;
|
|
172
|
+
return (deliver);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
# validate if we need to cache it and prevent from setting cookie
|
|
176
|
+
if (beresp.ttl > 0s && (bereq.method == "GET" || bereq.method == "HEAD")) {
|
|
177
|
+
unset beresp.http.set-cookie;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
# If page is not cacheable then bypass varnish for 2 minutes as Hit-For-Pass
|
|
181
|
+
if (beresp.ttl <= 0s ||
|
|
182
|
+
beresp.http.Surrogate-control ~ "no-store" ||
|
|
183
|
+
(!beresp.http.Surrogate-Control &&
|
|
184
|
+
beresp.http.Cache-Control ~ "no-cache|no-store") ||
|
|
185
|
+
beresp.http.Vary == "*") {
|
|
186
|
+
# Mark as Hit-For-Pass for the next 2 minutes
|
|
187
|
+
set beresp.ttl = 120s;
|
|
188
|
+
set beresp.uncacheable = true;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return (deliver);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
sub vcl_deliver {
|
|
195
|
+
if (resp.http.X-Magento-Debug) {
|
|
196
|
+
if (resp.http.x-varnish ~ " ") {
|
|
197
|
+
set resp.http.X-Magento-Cache-Debug = "HIT";
|
|
198
|
+
set resp.http.Grace = req.http.grace;
|
|
199
|
+
} else {
|
|
200
|
+
set resp.http.X-Magento-Cache-Debug = "MISS";
|
|
201
|
+
}
|
|
202
|
+
} else {
|
|
203
|
+
unset resp.http.Age;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
# Not letting browser to cache non-static files.
|
|
207
|
+
if (resp.http.Cache-Control !~ "private" && req.url !~ "^/(pub/)?(media|static)/") {
|
|
208
|
+
set resp.http.Pragma = "no-cache";
|
|
209
|
+
set resp.http.Expires = "-1";
|
|
210
|
+
set resp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0";
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
unset resp.http.X-Magento-Debug;
|
|
214
|
+
unset resp.http.X-Magento-Tags;
|
|
215
|
+
unset resp.http.X-Powered-By;
|
|
216
|
+
unset resp.http.Server;
|
|
217
|
+
unset resp.http.X-Varnish;
|
|
218
|
+
unset resp.http.Via;
|
|
219
|
+
unset resp.http.Link;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
sub vcl_hit {
|
|
223
|
+
if (obj.ttl >= 0s) {
|
|
224
|
+
# Hit within TTL period
|
|
225
|
+
return (deliver);
|
|
226
|
+
}
|
|
227
|
+
if (std.healthy(req.backend_hint)) {
|
|
228
|
+
if (obj.ttl + 300s > 0s) {
|
|
229
|
+
# Hit after TTL expiration, but within grace period
|
|
230
|
+
set req.http.grace = "normal (healthy server)";
|
|
231
|
+
return (deliver);
|
|
232
|
+
} else {
|
|
233
|
+
# Hit after TTL and grace expiration
|
|
234
|
+
return (restart);
|
|
235
|
+
}
|
|
236
|
+
} else {
|
|
237
|
+
# server is not healthy, retrieve from cache
|
|
238
|
+
set req.http.grace = "unlimited (unhealthy server)";
|
|
239
|
+
return (deliver);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
@@ -18,6 +18,10 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
18
18
|
SimpleXML: {},
|
|
19
19
|
xdebug: {
|
|
20
20
|
version: '3.1.2'
|
|
21
|
+
},
|
|
22
|
+
apcu: {},
|
|
23
|
+
opcache: {
|
|
24
|
+
extensionName: 'Zend OPcache'
|
|
21
25
|
}
|
|
22
26
|
}
|
|
23
27
|
},
|
|
@@ -39,6 +43,11 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
39
43
|
},
|
|
40
44
|
composer: {
|
|
41
45
|
version: '1'
|
|
46
|
+
},
|
|
47
|
+
varnish: {
|
|
48
|
+
enabled: true,
|
|
49
|
+
version: '5',
|
|
50
|
+
configTemplate: path.join(templateDir || '', 'varnish.template.vcl')
|
|
42
51
|
}
|
|
43
52
|
},
|
|
44
53
|
magento: defaultMagentoConfig,
|
|
@@ -18,6 +18,10 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
18
18
|
SimpleXML: {},
|
|
19
19
|
xdebug: {
|
|
20
20
|
version: '3.1.2'
|
|
21
|
+
},
|
|
22
|
+
apcu: {},
|
|
23
|
+
opcache: {
|
|
24
|
+
extensionName: 'Zend OPcache'
|
|
21
25
|
}
|
|
22
26
|
}
|
|
23
27
|
},
|
|
@@ -39,6 +43,11 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
39
43
|
},
|
|
40
44
|
composer: {
|
|
41
45
|
version: '1'
|
|
46
|
+
},
|
|
47
|
+
varnish: {
|
|
48
|
+
enabled: true,
|
|
49
|
+
version: '5',
|
|
50
|
+
configTemplate: path.join(templateDir || '', 'varnish.template.vcl')
|
|
42
51
|
}
|
|
43
52
|
},
|
|
44
53
|
magento: defaultMagentoConfig,
|
|
@@ -18,6 +18,10 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
18
18
|
SimpleXML: {},
|
|
19
19
|
xdebug: {
|
|
20
20
|
version: '3.1.2'
|
|
21
|
+
},
|
|
22
|
+
apcu: {},
|
|
23
|
+
opcache: {
|
|
24
|
+
extensionName: 'Zend OPcache'
|
|
21
25
|
}
|
|
22
26
|
}
|
|
23
27
|
},
|
|
@@ -39,6 +43,11 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
39
43
|
},
|
|
40
44
|
composer: {
|
|
41
45
|
version: '1'
|
|
46
|
+
},
|
|
47
|
+
varnish: {
|
|
48
|
+
enabled: true,
|
|
49
|
+
version: '5',
|
|
50
|
+
configTemplate: path.join(templateDir || '', 'varnish.template.vcl')
|
|
42
51
|
}
|
|
43
52
|
},
|
|
44
53
|
magento: defaultMagentoConfig,
|
|
@@ -18,6 +18,10 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
18
18
|
SimpleXML: {},
|
|
19
19
|
xdebug: {
|
|
20
20
|
version: '3.1.2'
|
|
21
|
+
},
|
|
22
|
+
apcu: {},
|
|
23
|
+
opcache: {
|
|
24
|
+
extensionName: 'Zend OPcache'
|
|
21
25
|
}
|
|
22
26
|
}
|
|
23
27
|
},
|
|
@@ -39,6 +43,11 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
39
43
|
},
|
|
40
44
|
composer: {
|
|
41
45
|
version: '1'
|
|
46
|
+
},
|
|
47
|
+
varnish: {
|
|
48
|
+
enabled: true,
|
|
49
|
+
version: '5',
|
|
50
|
+
configTemplate: path.join(templateDir || '', 'varnish.template.vcl')
|
|
42
51
|
}
|
|
43
52
|
},
|
|
44
53
|
magento: defaultMagentoConfig,
|
|
@@ -18,6 +18,10 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
18
18
|
SimpleXML: {},
|
|
19
19
|
xdebug: {
|
|
20
20
|
version: '3.1.2'
|
|
21
|
+
},
|
|
22
|
+
apcu: {},
|
|
23
|
+
opcache: {
|
|
24
|
+
extensionName: 'Zend OPcache'
|
|
21
25
|
}
|
|
22
26
|
}
|
|
23
27
|
},
|
|
@@ -39,6 +43,11 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
39
43
|
},
|
|
40
44
|
composer: {
|
|
41
45
|
version: '1'
|
|
46
|
+
},
|
|
47
|
+
varnish: {
|
|
48
|
+
enabled: true,
|
|
49
|
+
version: '6.2',
|
|
50
|
+
configTemplate: path.join(templateDir || '', 'varnish.template.vcl')
|
|
42
51
|
}
|
|
43
52
|
},
|
|
44
53
|
magento: defaultMagentoConfig,
|
|
@@ -18,6 +18,10 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
18
18
|
SimpleXML: {},
|
|
19
19
|
xdebug: {
|
|
20
20
|
version: '3.1.2'
|
|
21
|
+
},
|
|
22
|
+
apcu: {},
|
|
23
|
+
opcache: {
|
|
24
|
+
extensionName: 'Zend OPcache'
|
|
21
25
|
}
|
|
22
26
|
}
|
|
23
27
|
},
|
|
@@ -39,6 +43,11 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
39
43
|
},
|
|
40
44
|
composer: {
|
|
41
45
|
version: '1'
|
|
46
|
+
},
|
|
47
|
+
varnish: {
|
|
48
|
+
enabled: true,
|
|
49
|
+
version: '6.2',
|
|
50
|
+
configTemplate: path.join(templateDir || '', 'varnish.template.vcl')
|
|
42
51
|
}
|
|
43
52
|
},
|
|
44
53
|
magento: defaultMagentoConfig,
|
|
@@ -18,6 +18,10 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
18
18
|
SimpleXML: {},
|
|
19
19
|
xdebug: {
|
|
20
20
|
version: '3.1.2'
|
|
21
|
+
},
|
|
22
|
+
apcu: {},
|
|
23
|
+
opcache: {
|
|
24
|
+
extensionName: 'Zend OPcache'
|
|
21
25
|
}
|
|
22
26
|
}
|
|
23
27
|
},
|
|
@@ -39,6 +43,11 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
39
43
|
},
|
|
40
44
|
composer: {
|
|
41
45
|
version: '1'
|
|
46
|
+
},
|
|
47
|
+
varnish: {
|
|
48
|
+
enabled: true,
|
|
49
|
+
version: '6.2',
|
|
50
|
+
configTemplate: path.join(templateDir || '', 'varnish.template.vcl')
|
|
42
51
|
}
|
|
43
52
|
},
|
|
44
53
|
magento: defaultMagentoConfig,
|
|
@@ -18,6 +18,10 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
18
18
|
SimpleXML: {},
|
|
19
19
|
xdebug: {
|
|
20
20
|
version: '3.1.2'
|
|
21
|
+
},
|
|
22
|
+
apcu: {},
|
|
23
|
+
opcache: {
|
|
24
|
+
extensionName: 'Zend OPcache'
|
|
21
25
|
}
|
|
22
26
|
}
|
|
23
27
|
},
|
|
@@ -39,6 +43,11 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
39
43
|
},
|
|
40
44
|
composer: {
|
|
41
45
|
version: '1'
|
|
46
|
+
},
|
|
47
|
+
varnish: {
|
|
48
|
+
enabled: true,
|
|
49
|
+
version: '6.2',
|
|
50
|
+
configTemplate: path.join(templateDir || '', 'varnish.template.vcl')
|
|
42
51
|
}
|
|
43
52
|
},
|
|
44
53
|
magento: defaultMagentoConfig,
|