You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22-28
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
####Optimising Magento 2 with Varnish Cache, Redis and Nginx SSL termination on the Multi-container Architecture Using Docker-Compose tool.
1
+
### Optimising Magento 2 with Varnish Cache, Redis and Nginx SSL termination on the Multi-container Architecture Using Docker-Compose tool.
2
2
3
3
This repository corresponds to architecture setup as mentioned in blog https://cloudkul.com/blog/integrate-magento-2-varnish-cache-redis-server-ssl-termination-using-docker-compose/ .
4
4
@@ -30,46 +30,41 @@ Magento 2 works out of box with Varnish Cache and provides its own VCL file for
30
30
31
31
Nginx servers as reverse proxy server that receives traffic on port 80 and 443 and then proxy pass it to listening port of Varnish Cache server. It is done to deploy a way to direct both HTTP and HTTPS traffic to Varnish cache server which in turn, if needed, forward it apache2 server.
32
32
33
-
34
33
In this project, we are using:
35
34
36
-
> Operating system: Ubuntu 14.04
35
+
> Operating system: Ubuntu 16.04
37
36
38
37
> Web Server: Apache2
39
38
40
-
> Database Server: Mysql-server-5.6
39
+
> Database Server: Mysql-server-5.7
40
+
41
+
> Cache Server: Varnish 4.1
41
42
42
-
> Cache Server: Varnish 3.0.
43
+
> PHP version: PHP-7.1
43
44
44
45
> Redis server: Redis
45
46
46
47
> SSL server: Nginx 1.10.1
47
48
48
-
> PHP version: PHP-7.0
49
-
50
-
> Magento 2.1.6
51
-
52
-
To begin with, please install docker and docker-compose on your ubuntu 14.04 server.
49
+
To begin with, please install docker and docker-compose on your ubuntu server.
2) Set/modify mysql root credentials. Go to ~/magento2-varnish-redis-ssl-docker-compose/docker-compose.yml and change mysql root password in database_server in:
57
+
2) Set mysql root credentials and name of the database to be created in *database_server* block ~/magento2-varnish-redis-ssl-docker-compose/docker-compose.yml:
61
58
62
-
> mysql_password=rootpassword123
59
+
> mysql_password=
63
60
64
-
3). Modify change database name, database user and mysql root credentials in ~/magento2-varnish-redis-ssl-docker-compose/database_server/mysql.sh in:
61
+
> mysql_database=
65
62
66
-
> database_name=magento_db ## Mention database name
63
+
3). Download Magento 2 version you wish to dockerize and upload it in directory magento2 in parallel docker-compose.yml.
67
64
68
-
> database_user=magento_user ## Mention database user
65
+
> Go to https://magento.com/tech-resources/download? .
69
66
70
-
> database_root_password=rootpassword123 ## Mention mysql root password.
71
-
72
-
4). Replace the IP address assigned to 'server_name' in ~/magento2-varnish-redis-ssl-docker-compose/ssl_server/default with your domain name or IP address.
67
+
4). Replace localhost in 'server_name' in ~/magento2-varnish-redis-ssl-docker-compose/ssl_server/default with your domain name or IP address.
73
68
74
69
5). Build the docker image.
75
70
@@ -89,18 +84,11 @@ Then follow the following steps:
89
84
90
85
> docker ps
91
86
92
-
9). Your database credentials are mentioned in mysql.sh file. Database user password will be randomly generated. Database user password will be stored in /var/log/check.log. To get database user password,
93
-
94
-
> docker exec -ti mysql bash
95
-
96
-
> cat /var/log/check.log
97
-
98
-
or,
99
-
100
-
> docker exec -i mysql cat /var/log/check.log
101
87
102
88
Now, your server setup is all ready, now hit your domain name or IP to install Magento 2. Now to configure Varnish for Magento 2 and test its working, please refer to blog https://cloudkul.com/blog/magento-2-and-varnish-cache-integration-with-docker-compose/.
103
89
90
+
> Use Database host as mysql (name or id of the mysql container).
91
+
104
92
To configure Magento 2 for redis-server, please refer to blog https://cloudkul.com/blog/integrate-magento-2-varnish-cache-redis-server-ssl-termination-using-docker-compose/ .
105
93
106
94
@@ -109,3 +97,9 @@ To configure Magento 2 for redis-server, please refer to blog https://cloudkul.c
109
97
Although we had secured our application code keeping it on our host but database is as important as server code. So in order to keep their backup we schedule a shell script that will take backups of all the databases present in mysql-server container and keep them in archived from on our host. Shell script is present on ~/magento2-varnish-redis-ssl-docker-compose/backups/db_backup.sh. Please refer to blog https://cloudkul.com/blog/integrate-magento-2-varnish-cache-redis-server-ssl-termination-using-docker-compose/ for backup management.
110
98
111
99
If you face any issues, kindly report back.
100
+
101
+
102
+
#### GETTING SUPPORT
103
+
104
+
If you have any issues, contact us at [email protected] or raise ticket at https://webkul.uvdesk.com/
fordatabasein`echo 'show databases;'| docker exec -i mysql mysql --user=root --password=$mysql_root_password| grep -v Database | grep -v information_schema | grep -v mysql | grep -v performance_schema`
13
+
fordatabasein`echo 'show databases;'| docker exec -i mysql mysql --user=root --password=$MYSQL_ROOT_PASSWORD| grep -v Database | grep -v information_schema | grep -v mysql | grep -v performance_schema`
13
14
do
14
15
echo$database
15
-
docker exec$container_name mysqldump -u root -p$mysql_root_password$database>$database-$DATE.sql && tar -zcvf $database-$DATE.tar.gz $database-$DATE.sql && rm $database-$DATE.sql &&echo"$database-$DATE.tar.gz has been created on `date`">> database_backup.log
16
+
docker exec$container_name mysqldump -u root -p$MYSQL_ROOT_PASSWORD$database>$database-$DATE.sql && tar -zcvf $database-$DATE.tar.gz $database-$DATE.sql && rm $database-$DATE.sql &&echo"$database-$DATE.tar.gz has been created on `date`">> database_backup.log
# Remove Google gclid parameters to minimize the cache objects
89
+
setreq.url = regsuball(req.url,"\?gclid=[^&]+$",""); # strips when QS = "?gclid=AAA"
90
+
setreq.url = regsuball(req.url,"\?gclid=[^&]+&","?"); # strips when QS = "?gclid=AAA&foo=bar"
91
+
setreq.url = regsuball(req.url,"&gclid=[^&]+",""); # strips when QS = "?foo=bar&gclid=AAA" or QS = "?foo=bar&gclid=AAA&bar=baz"
92
+
93
+
# Static files caching
94
+
if (req.url ~ "^/(pub/)?(media|static)/") {
95
+
# Static files should not be cached by default
96
+
return (pass);
97
+
98
+
# 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
0 commit comments