# /** # * @version 2.4 # * @package Engintron for cPanel/WHM # * @author Fotis Evangelou (https://kodeka.io) # * @url https://engintron.com # * @copyright Copyright (c) 2014 - 2024 Kodeka OÜ. All rights reserved. # * @license GNU/GPL license: https://www.gnu.org/copyleft/gpl.html # */ # Common definitions for HTTP content # Initialize important variables set $CACHE_BYPASS_FOR_DYNAMIC 0; set $CACHE_BYPASS_FOR_STATIC 0; set $PROXY_DOMAIN_OR_IP $host; set $PROXY_FORWARDED_HOST $host; set $PROXY_SCHEME $scheme; set $SITE_URI "$host$request_uri"; # Generic query string to request a page bypassing Nginx's caching entirely for both dynamic & static content if ($query_string ~* "nocache") { set $CACHE_BYPASS_FOR_DYNAMIC 1; set $CACHE_BYPASS_FOR_STATIC 1; } # Proxy requests to "localhost" if ($host ~* "localhost") { set $PROXY_DOMAIN_OR_IP "127.0.0.1"; } # Disable caching for cPanel specific subdomains if ($host ~* "^(webmail|cpanel|whm|webdisk|cpcalendars|cpcontacts)\.") { set $CACHE_BYPASS_FOR_DYNAMIC 1; set $CACHE_BYPASS_FOR_STATIC 1; } # Fix Horde webmail forwarding if ($host ~* "^webmail\.") { set $PROXY_FORWARDED_HOST ''; } # Set custom rules like domain/IP exclusions or redirects here include custom_rules; location / { try_files $uri $uri/ @backend; } location @backend { include proxy_params_common; # === MICRO CACHING === # Comment the following line to disable 1 second micro-caching for dynamic HTML content include proxy_params_dynamic; } # Enable low duration browser cache for static data files (TTL is 1 min) location ~* \.(?:csv|json|xml|rss|atom)$ { include proxy_params_common; include proxy_params_static; expires 1m; } # Enable browser cache for CSS / JS (TTL is 30 days) location ~* \.(?:css|js)$ { include proxy_params_common; include proxy_params_static; expires 30d; } # Enable browser cache for images (TTL is 60 days) location ~* \.(?:ico|jpg|jpeg|gif|png|webp)$ { include proxy_params_common; include proxy_params_static; expires 60d; } # Enable browser cache for fonts & fix @font-face cross-domain restriction (TTL is 60 days) location ~* \.(eot|ttf|otf|woff|woff2|svg|svgz)$ { include proxy_params_common; include proxy_params_static; expires 60d; } # Prevent logging of favicon and robot request errors location = /favicon.ico { include proxy_params_common; include proxy_params_static; expires 60d; log_not_found off; } location = /robots.txt { include proxy_params_common; include proxy_params_static; expires 1d; log_not_found off; } # Deny access to files like .htaccess or .htpasswd location ~ /\.ht { deny all; }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
conf.d | Folder | 0755 |
|
|
utilities | Folder | 0755 |
|
|
common_http.conf | File | 2.67 KB | 0644 |
|
common_https.conf | File | 2.24 KB | 0644 |
|
common_simple_protection.conf | File | 8.07 KB | 0644 |
|
custom_rules | File | 6.88 KB | 0644 |
|
mime.types | File | 7.66 KB | 0644 |
|
nginx.conf | File | 5.1 KB | 0644 |
|
proxy_params_common | File | 1.56 KB | 0644 |
|
proxy_params_dynamic | File | 4.61 KB | 0644 |
|
proxy_params_static | File | 2.24 KB | 0644 |
|