Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Turn Nginx and VCL configs into reusable format strings #66

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 9 additions & 26 deletions component/varnish/resources/varnish/kodekit.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ probe health
#.url = "/varnish-enabled";
# We prefer to only do a HEAD /
.request =
"HEAD /varnish-enabled HTTP/1.1"
"Host: localhost"
"Connection: close";
"HEAD / HTTP/1.1"
"Host: localhost:%1$s"
"Connection: close"
"User-Agent: Varnish Health Probe";
.interval = 5s; # check the health of each backend every 5 seconds
.timeout = 1s; # timing out after 1 second.
Expand All @@ -24,7 +24,7 @@ probe health
backend default
{
.host = "127.0.0.1"; # IP or Hostname of backend
.port = "8080"; # Port Apache or whatever is listening
.port = "%1$s"; # Port Apache or whatever is listening
.max_connections = 300; # That's it
.probe = health;
.connect_timeout = 600s; # How long to wait before we receive a first byte from our backend?
Expand All @@ -35,7 +35,7 @@ backend default
backend passthrough
{
.host = "127.0.0.1"; # IP or Hostname of backend
.port = "8080"; # Port Apache or whatever is listening
.port = "%1$s"; # Port Apache or whatever is listening
}

acl localhost
Expand Down Expand Up @@ -113,36 +113,19 @@ sub vcl_recv
return (pass);
}

# Specific Nooku Platform rules
# Specific Kodekit Platform rules

# Do not cache /administrator
if(req.url ~ "^/administrator") {
return (pass);
}

# Specific Nooku Server rules

# Do not cache webgrind.nooku.dev
if (req.http.host == "webgrind.nooku.dev") {
return (pass);
}

# Do not cache phpmyadmin.nooku.dev
if (req.http.host == "phpmyadmin.nooku.dev") {
return (pass);
}

# Do not cache /apc and /phpinfo
if (req.url == "/apc" || req.url == "/phpinfo") {
return (pass);
}

# Generic URL manipulation, useful for all templates that follow

# Remove the Google Analytics added parameters, useless for our backend
if (req.url ~ "(\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=") {
set req.url = regsuball(req.url, "&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\-\.%25]+)", "");
set req.url = regsuball(req.url, "\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\-\.%25]+)", "?");
set req.url = regsuball(req.url, "&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\-\.%%25]+)", "");
set req.url = regsuball(req.url, "\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\-\.%%25]+)", "?");
set req.url = regsub(req.url, "\?&", "?");
set req.url = regsub(req.url, "\?$", "");
}
Expand Down Expand Up @@ -374,7 +357,7 @@ sub vcl_backend_response
# Large static files are delivered directly to the end-user without waiting for Varnish to fully read the
# file first. Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend
# doesn't send a Content-Length header. Only enable it for large files
if (bereq.url ~ "^[^?]*\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\?.*)?$") {
if (bereq.url ~ "^[^?]*\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\?.*)?$")
{
unset beresp.http.Set-Cookie;

Expand Down
18 changes: 9 additions & 9 deletions install/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
server {
listen 80;
server_name localhost;
listen *:%3$s;
server_name %1$s.test www.%1$s.test %1$s.dev www.%1$s.dev;

root /var/www/nooku-server/source;
root %2$s;

access_log /var/log/nginx/nooku-server.access.log;
error_log /var/log/nginx/nooku-server.error.log;
access_log /var/log/nginx/%1$s.access.log;
error_log /var/log/nginx/%1$s.error.log;

location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }

# turn sendfile feature on
senfile on;
sendfile on;

# prevent hidden files (beginning with a period) from being served
location ~ /\. { access_log off; log_not_found off; deny all; }
Expand Down Expand Up @@ -45,11 +45,11 @@ server {
# for security reasons the next line is highly encouraged
try_files $uri =404;

fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_pass %4$s;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
}
Expand Down