Skip to content

Instantly share code, notes, and snippets.

@LeMaX10
Last active June 2, 2022 07:20
Show Gist options
  • Select an option

  • Save LeMaX10/3b0e4996e6c13f8c906d7680a6838779 to your computer and use it in GitHub Desktop.

Select an option

Save LeMaX10/3b0e4996e6c13f8c906d7680a6838779 to your computer and use it in GitHub Desktop.

Revisions

  1. LeMaX10 revised this gist Dec 9, 2020. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -30,6 +30,13 @@ server {
    expires max;
    }

    location /combine {
    expires max;
    access_log off;

    rewrite ^/.*$ /index.php last;
    }

    try_files /storage/page-cache/$uri.html /storage/page-cache/$uri.json @rewrite;
    }

  2. LeMaX10 revised this gist Dec 1, 2020. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -14,6 +14,10 @@ server {
    if ($http_x_requested_with = XMLHttpRequest) {
    rewrite ^/.*$ /index.php last;
    }

    if ($request_method ~ ^(POST|PATCH|PUT|DELETE)$) {
    rewrite ^/.*$ /index.php last;
    }

    location = / {
    try_files /storage/page-cache/pc__index__pc.html @rewrite;
  3. LeMaX10 revised this gist Dec 1, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,7 @@ server {

    location / {
    location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
    sendfile on;
    sendfile on;
    access_log off;
    expires max;
    }
  4. LeMaX10 revised this gist Dec 1, 2020. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,11 @@ server {
    ssl on;
    ssl_certificate {pathToPemCertificate};
    ssl_certificate_key {pathToCertificateKey};


    if ($http_x_requested_with = XMLHttpRequest) {
    rewrite ^/.*$ /index.php last;
    }

    location = / {
    try_files /storage/page-cache/pc__index__pc.html @rewrite;
    }
  5. LeMaX10 created this gist Dec 1, 2020.
    85 changes: 85 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,85 @@
    server {
    listen {ip}:443 ssl http2;
    server_name {domain};
    root {rootPath};
    index index.php index.html index.htm;
    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}.log error;

    ssl on;
    ssl_certificate {pathToPemCertificate};
    ssl_certificate_key {pathToCertificateKey};

    location = / {
    try_files /storage/page-cache/pc__index__pc.html @rewrite;
    }

    location / {
    location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
    sendfile on;
    access_log off;
    expires max;
    }

    try_files /storage/page-cache/$uri.html /storage/page-cache/$uri.json @rewrite;
    }

    location @rewrite {
    rewrite ^/.*$ /index.php last;
    }

    location ~ ^/index.php {
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    if (!-f $document_root$fastcgi_script_name) {
    return 404;
    }

    fastcgi_pass unix:/var/run/php/www.sock;
    fastcgi_index index.php;
    include /etc/nginx/fastcgi_params;
    }

    location ~* "/\.(htaccess|htpasswd|env)$" {
    deny all;
    return 404;
    }

    # Whitelist
    ## Let October handle if static file not exists
    location ~ ^/favicon\.ico { try_files $uri /index.php; }
    location ~ ^/sitemap\.xml { try_files $uri /index.php; }
    location ~ ^/robots\.txt { try_files $uri /index.php; }
    location ~ ^/humans\.txt { try_files $uri /index.php; }

    ## Let nginx return 404 if static file not exists
    location ~ ^/storage/app/uploads/public { try_files $uri 404; }
    location ~ ^/storage/app/media { try_files $uri 404; }
    location ~ ^/storage/temp/public { try_files $uri 404; }

    location ~ ^/modules/.*/assets { try_files $uri 404; }
    location ~ ^/modules/.*/resources { try_files $uri 404; }
    location ~ ^/modules/.*/behaviors/.*/assets { try_files $uri 404; }
    location ~ ^/modules/.*/behaviors/.*/resources { try_files $uri 404; }
    location ~ ^/modules/.*/widgets/.*/assets { try_files $uri 404; }
    location ~ ^/modules/.*/widgets/.*/resources { try_files $uri 404; }
    location ~ ^/modules/.*/formwidgets/.*/assets { try_files $uri 404; }
    location ~ ^/modules/.*/formwidgets/.*/resources { try_files $uri 404; }
    location ~ ^/modules/.*/reportwidgets/.*/assets { try_files $uri 404; }
    location ~ ^/modules/.*/reportwidgets/.*/resources { try_files $uri 404; }

    location ~ ^/plugins/.*/.*/assets { try_files $uri 404; }
    location ~ ^/plugins/.*/.*/resources { try_files $uri 404; }
    location ~ ^/plugins/.*/.*/behaviors/.*/assets { try_files $uri 404; }
    location ~ ^/plugins/.*/.*/behaviors/.*/resources { try_files $uri 404; }
    location ~ ^/plugins/.*/.*/reportwidgets/.*/assets { try_files $uri 404; }
    location ~ ^/plugins/.*/.*/reportwidgets/.*/resources { try_files $uri 404; }
    location ~ ^/plugins/.*/.*/formwidgets/.*/assets { try_files $uri 404; }
    location ~ ^/plugins/.*/.*/formwidgets/.*/resources { try_files $uri 404; }
    location ~ ^/plugins/.*/.*/widgets/.*/assets { try_files $uri 404; }
    location ~ ^/plugins/.*/.*/widgets/.*/resources { try_files $uri 404; }

    location ~ ^/themes/.*/assets { try_files $uri 404; }
    location ~ ^/themes/.*/resources { try_files $uri 404; }
    }