From 6db2cf48d537306a6c3f6466c1fb89864089fd40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szekeres=20Ba=CC=81lint?= Date: Sun, 2 Dec 2018 20:28:18 +0100 Subject: [PATCH] added Magento support fixes #48 --- README.md | 1 + public/assets/img/brands/magento.svg | 1 + public/assets/js/app.js | 9 ++ public/index.html | 26 +++++- .../conf/nginxconfig.io/magento.conf.html | 82 +++++++++++++++++++ .../sites-available/example.com.conf.html | 9 +- 6 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 public/assets/img/brands/magento.svg create mode 100644 public/templates/conf/nginxconfig.io/magento.conf.html diff --git a/README.md b/README.md index c68a29d..dae3ac7 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ * PHP backup server * WordPress security essentials * Drupal security essentials +* Magento security essentials ### Routing * `index` diff --git a/public/assets/img/brands/magento.svg b/public/assets/img/brands/magento.svg new file mode 100644 index 0000000..fe656cb --- /dev/null +++ b/public/assets/img/brands/magento.svg @@ -0,0 +1 @@ +Magento icon \ No newline at end of file diff --git a/public/assets/js/app.js b/public/assets/js/app.js index 9c3b847..68887f8 100644 --- a/public/assets/js/app.js +++ b/public/assets/js/app.js @@ -52,6 +52,7 @@ php_server_backup: '', wordpress: false, drupal: false, + magento: false, file_structure: 'modularized', symlink: true, @@ -379,6 +380,7 @@ $scope.data.php = $scope.defaultData.php; $scope.data.wordpress = $scope.defaultData.wordpress; $scope.data.drupal = $scope.defaultData.drupal; + $scope.data.magento = $scope.defaultData.magento; $scope.data.proxy = $scope.defaultData.proxy; $scope.data.index = $scope.defaultData.index; $scope.data.fallback_html = $scope.defaultData.fallback_html; @@ -402,6 +404,9 @@ case 'drupal': $scope.data.drupal = true; break; + case 'magento': + $scope.data.magento = true; + break; case 'nodejs': $scope.data.php = false; $scope.data.proxy = true; @@ -538,6 +543,10 @@ return $scope.isPHP() && $scope.data.drupal; }; + $scope.isMagento = function() { + return $scope.isPHP() && $scope.data.magento; + }; + $scope.isCSP = function() { return !!$scope.data.content_security_policy; }; diff --git a/public/index.html b/public/index.html index 5ec8e63..c3c6a99 100644 --- a/public/index.html +++ b/public/index.html @@ -8,9 +8,9 @@ nginxconfig.io - + - + @@ -29,6 +29,7 @@ +
@@ -442,6 +443,17 @@ +
+ +
+
+ + +
+
+
@@ -853,6 +865,16 @@
+
+ /etc/nginx/nginxconfig.io/magento.conf + + Copied! +
+
+
+
diff --git a/public/templates/conf/nginxconfig.io/magento.conf.html b/public/templates/conf/nginxconfig.io/magento.conf.html new file mode 100644 index 0000000..59c7590 --- /dev/null +++ b/public/templates/conf/nginxconfig.io/magento.conf.html @@ -0,0 +1,82 @@ +# Magento: setup +location ^~ /setup { + root $base; + + # allow index.php + location ~ ^/setup/index.php { + include nginxconfig.io/php_fastcgi.conf; + } + + # deny everything except pub + location ~ ^/setup/(?!pub/). { + deny all; + } +} + +# Magento: update +location ^~ /update { + root $base; + + # allow index.php + location ~ ^/update/index.php { + include nginxconfig.io/php_fastcgi.conf; + } + + # deny everything except pub + location ~ ^/update/(?!pub/). { + deny all; + } +} + +# Magento: media files +location ^~ /media/ { + try_files $uri $uri/ /get.php?$args; + + location ~* \.(?:ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ { + expires +1y; + add_header Cache-Control "public"; + try_files $uri $uri/ /get.php?$args; + } + + location ~* \.(?:zip|gz|gzip|bz2|csv|xml)$ { + expires off; + add_header Cache-Control "no-store"; + try_files $uri $uri/ /get.php?$args; + } + + location ~ ^/media/theme_customization/.*\.xml { + deny all; + } + + location ~ ^/media/(?:customer|downloadable|import)/ { + deny all; + } +} + +# Magento: static route +location @magento_static { + rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; +} + +# Magento: static files +location ^~ /static/ { + expires max; + try_files $uri $uri/ @magento_static; + + location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ { + expires +1y; + add_header Cache-Control "public"; + try_files $uri $uri/ @magento_static; + } + + location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { + expires off; + add_header Cache-Control "no-store"; + try_files $uri $uri/ @magento_static; + } +} + +# Magento: deny cron +location ~ cron\.php { + deny all; +} diff --git a/public/templates/conf/sites-available/example.com.conf.html b/public/templates/conf/sites-available/example.com.conf.html index bf3952d..b4e9b65 100644 --- a/public/templates/conf/sites-available/example.com.conf.html +++ b/public/templates/conf/sites-available/example.com.conf.html @@ -98,6 +98,9 @@ server { include nginxconfig.io/drupal.conf; + include nginxconfig.io/magento.conf; @@ -110,7 +113,11 @@ server { - + + + }