Skip to content

Instantly share code, notes, and snippets.

@pujianto
Created March 31, 2022 04:16
Show Gist options
  • Save pujianto/0b34819c8c21d0f2d6fbfc5a338eb36b to your computer and use it in GitHub Desktop.
Save pujianto/0b34819c8c21d0f2d6fbfc5a338eb36b to your computer and use it in GitHub Desktop.
WHM Serve static files directly from Nginx and fallback to apache if file no found. (WHM with Nginx Proxy Installed)
# Place this file inside /etc/nginx/conf.d/server-includes/
location @httpd_fallback {
proxy_pass $scheme://$CPANEL_APACHE_PROXY_REQ_IP:$CPANEL_APACHE_PROXY_REQ_PORT;
}
location ~ \.(gif|jpg|jpeg|png|css|js|svg|webm|webp)$ {
expires 30d;
add_header Vary Accept-Encoding;
access_log off;
tcp_nodelay off;
sendfile on;
sendfile_max_chunk 2m;
try_files $uri $uri/ @httpd_fallback;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment