Skip to content

Commit 7378752

Browse files
authored
Merge pull request #20 from ityetti/develop
Fixed to avoid the proxying cycle between varnish and nginx.
2 parents 5ccc15e + 19b2dcc commit 7378752

File tree

7 files changed

+358
-151
lines changed

7 files changed

+358
-151
lines changed

README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,84 @@ Install project (don't forget to change **--base-url** to yours):
113113
## Setting up Magento
114114
To access the magento homepage, go to the following url: https://magento2.test<br>
115115

116+
<details>
117+
118+
<summary>Storing sessions and cache in redis.</summary>
119+
120+
##### As reference, you could use `env.php.magento.sample`
121+
122+
#### Setting up the configuration for sessions.
123+
124+
```php
125+
'session' => [
126+
'save' => 'redis',
127+
'redis' => [
128+
'host' => 'redis',
129+
'port' => '6379',
130+
'password' => '',
131+
'timeout' => '2.5',
132+
'persistent_identifier' => '',
133+
'database' => '2',
134+
'compression_threshold' => '2048',
135+
'compression_library' => 'gzip',
136+
'log_level' => '1',
137+
'max_concurrency' => '6',
138+
'break_after_frontend' => '5',
139+
'break_after_adminhtml' => '30',
140+
'first_lifetime' => '600',
141+
'bot_first_lifetime' => '60',
142+
'bot_lifetime' => '7200',
143+
'disable_locking' => '0',
144+
'min_lifetime' => '60',
145+
'max_lifetime' => '2592000'
146+
]
147+
]
148+
```
149+
150+
#### Setting up the configuration for cache.
151+
152+
```php
153+
'cache' => [
154+
'frontend' => [
155+
'default' => [
156+
'id_prefix' => '777_',
157+
'backend' => 'Cm_Cache_Backend_Redis',
158+
'backend_options' => [
159+
'server' => 'redis',
160+
'database' => '0',
161+
'port' => '6379',
162+
'compress_data' => '1',
163+
'compress_tags' => '1'
164+
]
165+
],
166+
'page_cache' => [
167+
'id_prefix' => '777_',
168+
'backend' => 'Cm_Cache_Backend_Redis',
169+
'backend_options' => [
170+
'server' => 'redis',
171+
'port' => '6379',
172+
'database' => '1',
173+
'compress_data' => '0'
174+
]
175+
]
176+
],
177+
'allow_parallel_generation' => false
178+
],
179+
```
180+
181+
#### Don't forget to add `http_cache_hosts` to correct the varnish purge.
182+
183+
```php
184+
'http_cache_hosts' => [
185+
[
186+
'host' => 'nginx',
187+
'port' => '8080'
188+
]
189+
]
190+
```
191+
192+
</details>
193+
116194
## How to use xDebug
117195
You could enable or disable xDebug with the next command: `./scripts/switch_mode [fpm|xdebug]`<br>
118196
`fpm` - Enable container without xDebug <br>
@@ -138,6 +216,7 @@ https://rabbit.magento2.test - **RabbitMQ** (guest/guest for access)<br>
138216
- v1.0.8 - Replace mailhog to mailpit
139217
- v1.0.9 - Add n98-magerun2
140218
- v1.1.0 - Add a switcher for PHP that enables or disables xDebug
219+
- v1.1.1 - Fixed to avoid the proxying cycle between varnish and nginx.
141220

142221
## Branches
143222
| Name | Magento versions |

docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ services:
4343
- magento
4444
labels:
4545
- "traefik.enable=false"
46+
expose:
47+
- "8080"
4648

4749
php-fpm:
4850
build: ./php-fpm
@@ -221,7 +223,7 @@ services:
221223
- CACHE_SIZE=1G
222224
expose:
223225
- "6081"
224-
command: ["varnishd", "-F", "-a", ":6081", "-b", "nginx:80"]
226+
command: ["varnishd", "-F", "-a", ":6081", "-b", "nginx:8080"]
225227

226228
networks:
227229
magento:

env.php.magento.sample

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<?php
2+
return [
3+
'remote_storage' => [
4+
'driver' => 'file'
5+
],
6+
'backend' => [
7+
'frontName' => 'admin'
8+
],
9+
'cache' => [
10+
'graphql' => [
11+
'id_salt' => 'a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1'
12+
],
13+
'frontend' => [
14+
'default' => [
15+
'id_prefix' => '777_',
16+
'backend' => 'Cm_Cache_Backend_Redis',
17+
'backend_options' => [
18+
'server' => 'redis',
19+
'port' => '6379',
20+
'database' => '0',
21+
'compress_data' => '1',
22+
'compress_tags' => '1'
23+
]
24+
],
25+
'page_cache' => [
26+
'id_prefix' => '777_',
27+
'backend' => 'Cm_Cache_Backend_Redis',
28+
'backend_options' => [
29+
'server' => 'redis',
30+
'port' => '6379',
31+
'database' => '1',
32+
'compress_data' => '0'
33+
]
34+
]
35+
],
36+
'allow_parallel_generation' => false
37+
],
38+
'config' => [
39+
'async' => 0
40+
],
41+
'queue' => [
42+
'consumers_wait_for_messages' => 1
43+
],
44+
'crypt' => [
45+
'key' => 'base641+a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1'
46+
],
47+
'db' => [
48+
'table_prefix' => '',
49+
'connection' => [
50+
'default' => [
51+
'host' => 'mysql',
52+
'dbname' => 'magento_db',
53+
'username' => 'magento_user',
54+
'password' => 'PASSWD#',
55+
'model' => 'mysql4',
56+
'engine' => 'innodb',
57+
'initStatements' => 'SET NAMES utf8;',
58+
'active' => '1',
59+
'driver_options' => [
60+
1014 => false
61+
]
62+
]
63+
]
64+
],
65+
'resource' => [
66+
'default_setup' => [
67+
'connection' => 'default'
68+
]
69+
],
70+
'x-frame-options' => 'SAMEORIGIN',
71+
'MAGE_MODE' => 'developer',
72+
'session' => [
73+
'save' => 'redis',
74+
'redis' => [
75+
'host' => 'redis',
76+
'port' => '6379',
77+
'database' => '2',
78+
'password' => '',
79+
'timeout' => '2.5',
80+
'persistent_identifier' => '',
81+
'compression_threshold' => '2048',
82+
'compression_library' => 'gzip',
83+
'log_level' => '1',
84+
'max_concurrency' => '6',
85+
'break_after_frontend' => '5',
86+
'break_after_adminhtml' => '30',
87+
'first_lifetime' => '600',
88+
'bot_first_lifetime' => '60',
89+
'bot_lifetime' => '7200',
90+
'disable_locking' => '0',
91+
'min_lifetime' => '60',
92+
'max_lifetime' => '2592000'
93+
]
94+
],
95+
'lock' => [
96+
'provider' => 'db'
97+
],
98+
'directories' => [
99+
'document_root_is_pub' => true
100+
],
101+
'cache_types' => [
102+
'config' => 1,
103+
'layout' => 1,
104+
'block_html' => 1,
105+
'collections' => 1,
106+
'reflection' => 1,
107+
'db_ddl' => 1,
108+
'compiled_config' => 1,
109+
'eav' => 1,
110+
'customer_notification' => 1,
111+
'config_integration' => 1,
112+
'config_integration_api' => 1,
113+
'graphql_query_resolver_result' => 1,
114+
'full_page' => 1,
115+
'config_webservice' => 1,
116+
'translate' => 1
117+
],
118+
'downloadable_domains' => [
119+
'magento2.test'
120+
],
121+
'install' => [
122+
'date' => 'Tue, 26 Nov 2024 01:33:37 +0000'
123+
],
124+
'http_cache_hosts' => [
125+
[
126+
'host' => 'nginx',
127+
'port' => '8080'
128+
]
129+
]
130+
];

nginx/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ FROM arm64v8/nginx:1.22
33
RUN groupadd -g 2000 magento \
44
&& useradd -d /home/magento -u 2000 -g 2000 magento
55

6-
COPY ./nginx.conf /etc/nginx/nginx.conf
76
COPY ./default.conf /etc/nginx/conf.d/default.conf

0 commit comments

Comments
 (0)