Last active
June 2, 2022 07:20
-
-
Save LeMaX10/3b0e4996e6c13f8c906d7680a6838779 to your computer and use it in GitHub Desktop.
Nginx configuration for OctoberCMS with support Quicksilver plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}; | |
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; | |
} | |
location / { | |
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ { | |
sendfile on; | |
access_log off; | |
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; | |
} | |
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; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment