Browse Source

Update modx.tpl

Alexandros Ioannides 5 years ago
parent
commit
340add2fc9
1 changed files with 34 additions and 26 deletions
  1. 34 26
      install/deb/templates/web/nginx/php-fpm/modx.tpl

+ 34 - 26
install/deb/templates/web/nginx/php-fpm/modx.tpl

@@ -11,12 +11,9 @@ server {
     access_log  /var/log/nginx/domains/%domain%.log combined;
     access_log  /var/log/nginx/domains/%domain%.bytes bytes;
     error_log   /var/log/nginx/domains/%domain%.error.log error;
-        
+
     include %home%/%user%/conf/web/%domain%/nginx.forcessl.conf*;
-#   if you need to rewrite www to non-www uncomment bellow
-#   if ($host != '%domain%' ) {
-#       rewrite      ^/(.*)$  http://%domain%/$1  permanent;
-#    }
+
     location = /favicon.ico {
         log_not_found off;
         access_log off;
@@ -28,41 +25,52 @@ server {
         access_log off;
     }
 
-    location / {
-        try_files $uri $uri/ @rewrite;
-        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
-            expires     max;
-            fastcgi_hide_header "Set-Cookie";
-        }
+    location ~ /\.(?!well-known\/) {
+        deny all;
+        return 404;
+    }
+
+    location /core/ {
+        deny all;
+        return 404;
     }
+
     location @rewrite {
         rewrite ^/(.*)$ /index.php?q=$1;
     }
 
-    location ~ \.php$ {
-        try_files $uri =404;
-        fastcgi_pass %backend_lsnr%;
-        fastcgi_index index.php;
-        fastcgi_param SCRIPT_FILENAME $request_filename;
-        include /etc/nginx/fastcgi_params;
-        include     %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf*;
+    location / {
+        try_files $uri $uri/ @rewrite;
+        location ~* ^.+\.(ogg|ogv|svg|svgz|swf|eot|otf|woff|woff2|mov|mp3|mp4|webm|flv|ttf|rss|atom|jpg|jpeg|gif|png|ico|bmp|mid|midi|wav|rtf|css|js|jar)$ {
+            expires 30d;
+            fastcgi_hide_header "Set-Cookie";
+        }
+
+        location ~ [^/]\.php(/|$) {
+            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+            try_files $uri =404;
+            fastcgi_pass %backend_lsnr%;
+            fastcgi_index index.php;
+            include /etc/nginx/fastcgi_params;
+            include %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf*;
+                if ($request_uri ~* "/manager/|index.php") {
+                    set $no_cache 1;
+                }
+                if ($http_cookie ~ SESS) {
+                    set $no_cache 1;
+                }
     }
 
     location /error/ {
         alias   %home%/%user%/web/%domain%/document_errors/;
     }
 
-    location ~ /\.(?!well-known\/) { 
-       deny all; 
-       return 404;
-    }
-
     location /vstats/ {
         alias   %home%/%user%/web/%domain%/stats/;
         include %home%/%user%/web/%domain%/stats/auth.conf*;
     }
 
-    include     /etc/nginx/conf.d/phpmyadmin.inc*;
-    include     /etc/nginx/conf.d/phppgadmin.inc*;
-    include     %home%/%user%/conf/web/%domain%/nginx.conf_*;
+    include /etc/nginx/conf.d/phpmyadmin.inc*;
+    include /etc/nginx/conf.d/phppgadmin.inc*;
+    include %home%/%user%/conf/web/%domain%/nginx.conf_*;
 }