I have varnish, and don't remember adding specific code to get it working, by default it works already fin, or I don't understand your question CyberAP.
location ~* (^(?!(?:(?!(php|inc)).)*/uploads/).*?(php)) {
try_files $uri = 404;
fastcgi_split_path_info ^(.+.php)(.*)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
location /xf {
try_files $uri $uri/ /index.php?$uri&$args;
}
I'm using Varnish as frontend, is it what you want too ?
## Alternative 2, Configuration with VCL
#
# Listen on port 6081, administration on localhost:6082, and forward to
# one content server selected by the vcl file, based on the request. Use a 1GB
# fixed-size cache file.
#
DAEMON_OPTS="-a :80 \
-T localhost:6082 \
-f /etc/varnish/default.vcl \
-S /etc/varnish/secret \
-s malloc,128m"
# Normalize gzip compression
if( req.http.Accept-Encoding )
{
if( req.url ~ "(?i)(\.|-)(jpe?g|png|gif|gz|tgz|bz2|tbz|mp3|ogg)(.*)?$" )
{
remove req.http.Accept-Encoding;
}
elseif( req.http.Accept-Encoding ~ "gzip" )
{
set req.http.Accept-Encoding = "gzip";
}
elsif( req.http.Accept-Encoding ~ "deflate" )
{
set req.http.Accept-Encoding = "deflate";
}
else
{
remove req.http.Accept-Encoding;
}
}
# Use anonymous, cached pages if all backends are down.
# Remove cookies from things that should be static, if any are set
if( req.url ~ "(?i)(\.|-)(jpg|jpeg|gif|png|ico|gz|svg|svgz|mp4|ogg|ogv|css|js|ttf|ttc|otf|eot|woff|ico)(?:\.[0-9]+|(\?[a-zA-Z0-9\=\.\-_]+)?)$" )
{
remove req.http.Set-Cookie;
remove req.http.Cookie;
set req.url = regsub( req.url, "^/.*$", "" );
return ( lookup );
}
# Remove Google Analytics.
if( req.http.Cookie )
{
# Some generic URL manipulation, useful for all templates that follow
# First remove the Google Analytics added parameters, useless for our backend
if( req.url ~ "(\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=" )
{
set req.url = regsuball(req.url, "&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\-\.%25]+)", "" );
set req.url = regsuball(req.url, "\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\-\.%25]+)", "?" );
set req.url = regsub(req.url, "\?&", "?" );
set req.url = regsub(req.url, "\?$", "" );
}
if( req.url ~ "\?$" )
{
set req.url = regsub(req.url, "\?$", "" );
}
set req.http.Cookie = regsuball( req.http.Cookie, "(^|;\s*)(__[a-z]+|has_js)=[^;]*", "" );
# Some generic cookie manipulation, useful for all templates that follow
# Remove the "has_js" cookie
set req.http.Cookie = regsuball( req.http.Cookie, "has_js=[^;]+(; )?", "");
# Remove any Google Analytics based cookies
set req.http.Cookie = regsuball( req.http.Cookie, "__utm.=[^;]+(; )?", "" );
set req.http.Cookie = regsuball( req.http.Cookie, "utmctr=[^;]+(; )?", "" );
set req.http.Cookie = regsuball( req.http.Cookie, "utmcmd.=[^;]+(; )?", "" );
set req.http.Cookie = regsuball( req.http.Cookie, "utmccn.=[^;]+(; )?", "" );
}
if( req.http.Cookie == "" )
{
remove req.http.Cookie;
}
# Adjusting Varnish's caching - hold on to all cachable objects fo 24 hours.
# Objects declared explicibly as uncacheable are held for 60 seconds, which
# helps in the event of a sudden ridiculous rush of traffic.
if( beresp.ttl < 24h )
{
if( beresp.http.Cache-Control ~ "(private|no-cache|no-store)" )
{
set beresp.ttl = 60s;
}
else
{
set beresp.ttl = 24h;
}
}
if( req.url ~ "(?i)(\.|-)(jpg|jpeg|gif|png|ico|gz|svg|svgz|mp4|ogg|ogv|css|js|ttf|ttc|otf|eot|woff|ico)(?:\.[0-9]+|(\?[a-zA-Z0-9\=\.\-_]+)?)$" )
{
set beresp.http.X-Varnish-Action = "FETCH (deliver - static sontent)";
set beresp.ttl = 30d;
set beresp.http.Cache-Control = "public, max-age=31556926";
unset beresp.http.Set-Cookie;
unset beresp.http.Cookie;
set req.url = regsub( req.url, "\?.*$", "" );
return ( deliver );
}
elseif( beresp.http.Set-Cookie )
{
return( hit_for_pass );
}
elseif( beresp.http.Cache-Control ~ "(private|no-cache|no-store)" )
{
return( hit_for_pass );
}
elseif( req.http.Authorization && !beresp.http.Cache-Control ~ "public" )
{
return( hit_for_pass );
}
if( req.http.host == "www.mysite.com" )
{
error 301;
}
if( obj.status == 301 && req.http.host == "www.mysite.com" )
{
set obj.http.Location = "http://mysite.com" + req.url;
set obj.status = 301;
return( deliver );
}
sub vcl_error
{
if( obj.status == 301 && req.http.host == "www.mysite.com" )
{
set obj.http.Location = "http://mysite.com" + req.url;
set obj.status = 301;
return( deliver );
}
elseif( obj.status == 700 )
{
# Include a general error message handler for debugging purposes
include "/etc/varnish/conf.d/_error.vcl";
}
elseif( obj.status == 701 )
{
# Redirect error handler
set obj.http.Location = "http://" + obj.response + req.url;
# Change this to 302 if you want temporary redirects
set obj.status = 301;
return (deliver);
}
elseif( obj.status == 503 && req.restarts < 5 )
{
set obj.http.X-Restarts = req.restarts;
return ( restart );
}
return ( deliver );
}
set_real_ip_from 127.0.0.1;
real_ip_header X-Forwarded-For;
server
{
listen 8080;
server_name www.mysite.com;
rewrite ^http://cs-amx.fr$request_uri? permanent;
}
server
{
listen 8080;
server_name mysite.com;
root /path/to/your/wwww;
index index.html index.htm index.php;
...
}
location /xf/ {
index index.php;
try_files $uri $uri/ /xf/index.php?$uri&$args;
}
I feel like I've lost my time written my previous message ; but what you say is wise. I remember having some trouble to adjust configuration at the start. So, yes, you should have first a solid nginx config ; and once all is working fine, if you feel you need to improve forum loading/reactivity, you could try to install it again. Varnish would be really worth if you have a lot of cacheable objects. If not, using nginx cache would be enough.
server {
listen 5443 default_server ssl;
server_name mysite;
location / {
proxy_pass http://127.0.0.1:6081;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_redirect off;
}
}
We use essential cookies to make this site work, and optional cookies to enhance your experience.