Giter Site home page Giter Site logo

varnish-nginx-wordpress's Introduction

varnish-nginx-wordpress's People

Contributors

aliymn avatar amferraz avatar nicolargo avatar oyabi avatar rhvs avatar shakaran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

varnish-nginx-wordpress's Issues

'conflict' between nginx global cache files

Is there any kind of "conflict" between globa/cache.conf and global/wordpress-w3-total-cache.conf files? They have some rules that seems to treat the same files. Wich one should prevail? Wich one should come first?

Thanks!

GET method cached.

Very good this setting, congratulations.

There is cached as all contents of the GET method?

I need to shorten the request to the database.

Wordpress 5.2.3 save page getting 301 redirect

Using your varnish 4 configuration we are having an issue with new Guttenburg block editor. When trying to save a page we are getting a 301 redirect and page content is not saving.

The request when press Publish button is the following:

Request URL: http://www.example.com/wp-json/wp/v2/pages/1688?_locale=user
Request Method: POST
Status Code: 301 Moved Permanently
Remote Address: 132.99.252.70:80
Referrer Policy: strict-origin-when-cross-origin

Our nginx is hosted on port 8080 and varnish on port 80. Website nginx configuration is redirecting example.com to www.example.com

Also for some reason we are getting www.example.com:8080 requests on some GET requests. We have esolved that by adding port_in_redirect off; on our nginx configuration.

Nginx Global Files

Hi, first of all, nice repo! =)

On the global dir, inside nginx folder, you have 5 conf files. But you actually just call two of them (php-fpm.conf and security.conf) inside the site-configuration/wordpress file. All other 3 files are never called anywhere, not even nginx.conf.

So, based on that, shouldn't cache.conf and wordpress-w3-total-cache.conf be called inside the wordpress conf file?

(status.conf may be called from another file, but it's not that important as far as I understand it's purpose)

Varnish returns cached page when trying to access my-account

Hi, I am using one of your wordpress configs for varnish ( varnish4 ) and everything works, but my admin area is unaccessible and seems also that it caches /my-account. Everytime I try to access the admin through the myaccount area or just log in a user, varnish returns a cached page so I can't login.

Any hints ?

Thanks

Error Compilation

With a exact copy of you VCL file, i obtain this error :

v3:/etc/varnish# /etc/init.d/varnish start
Starting HTTP accelerator: varnishd failed!
storage_file: filename: /var/lib/varnish/v3/varnish_storage.bin size 1024 MB.
Message from VCC-compiler:
Expected variable, string or semicolon
(input Line 39 Pos 81)
                        set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;
--------------------------------------------------------------------------------#------------------
Running VCC-compiler failed, exit 1
VCL compilation failed

On Debian Squeeze 32bits, with varnish 2.1.3-8

Blank page if logged

Hi,
I'm using the varnish 4 file for wordpress. Those 2 lines seems to be responsable of blank pages for logged users.

    # Check the cookies for wordpress-specific items
    if (req.http.Cookie ~ "wordpress_" || req.http.Cookie ~ "comment_") {
        #return (pass); <- THIS
    }
    if (!req.http.cookie) {
        unset req.http.cookie;
    }

    # --- End of Wordpress specific configuration

    # Did not cache HTTP authentication and HTTP Cookie
    if (req.http.Authorization || req.http.Cookie) {
        # Not cacheable by default
        #return (pass); <- AND THIS
    }

I'm using nginx and apache with a configuration a little bit different from this repository.
How can i fix it ?

http://www.isvarnishworking.com/ saying "no varnish " why?

hi !

i using your Default.vcl ..
i checked in http://www.isvarnishworking.com/ website, if my varnish (4) working..
and he said " NOPE ! "
how this possible ?

here my config details:

let say my server ip is :123.123.123.123

so this my configuration of Default.vcl:

backend default {
.host = "123.123.123.123";
.port = "8080";
.connect_timeout = 600s;
.first_byte_timeout = 600s;
.between_bytes_timeout = 600s;
.max_connections = 800;
}

Only allow purging from specific IPs

acl purge {
"localhost";
"127.0.0.1";
}

and in Nginx.conf :

server {
listen 123.123.123.123:80;
server_name mydomain.com www.mydomain.com;
error_log /var/log/httpd/domains/mydomain.com.error.log error;

location / {
    proxy_pass      http://123.123.123.123:6081;

    proxy_cache cache;
    proxy_cache_valid 15m;
    proxy_cache_valid 404 1m;
    proxy_no_cache $no_cache;
    proxy_cache_bypass $no_cache;
    proxy_cache_bypass $cookie_session $http_x_update;

    location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html$
        proxy_cache    off;
        root           /home/admin/web/mydomain.com/public_html;
        access_log     /var/log/httpd/domains/mydomain.com.log combined;
        access_log     /var/log/httpd/domains/mydomain.com.bytes bytes;
        expires        max;
        try_files      $uri @fallback;
    }
}

location /error/ {
    alias   /home/admin/web/mydomain.com/document_errors/;
}

location @fallback {
    proxy_pass      http://123.123.123.123:6081;
}

location ~ /\.ht    {return 404;}
location ~ /\.svn/  {return 404;}
location ~ /\.git/  {return 404;}
location ~ /\.hg/   {return 404;}
location ~ /\.bzr/  {return 404;}

include /home/admin/conf/web/nginx.mydomain.com.conf*;

}

i think this configurated correct. so why http://www.isvarnishworking.com/ say no varnish ?

Nope!
We didn't find the "X-Varnish" header in the response from the server so likely Varnish is, in fact, not working.

Shoot.

It is possible that the Varnish daemon is technically running on the server, but maybe listening on another port. It's also possible someone modified the headers in your Varnish installation - in which case you're out of luck pal!

And here, for you to ponder further, are the actual headers we received:

The url we checked: mydomain.com
HTTP/1.1 200 OK
Date: Tue, 06 Jan 2015 08:11:37 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Set-Cookie: __cfduid=d235e8244a0187f446c95c59f836c4abc1420531897; expires=Wed, 06-Jan-16 08:11:37 GMT; path=/; domain=.mydomain.com; HttpOnly
X-Pingback: http://mydomain.com/xmlrpc.php
Link: http://wp.me/58zon; rel=shortlink
Age: 42026
X-Cache: cached
Server: cloudflare-nginx
CF-RAY: 1a4672293c930697-EWR
Content-Encoding: gzip

And the headers we sent:

HEAD / HTTP/1.1

Host: mydomain.com
Accept: /
Accept-Encoding: gzip, deflate
Check another site!

regards,
Tomer.

Just a suggestion

To complete this setup, you should just create one more file and that is Nginx site example, so people know what to put there.

And your config is great and it works flawlessly. Thank you!

Port redirect in wp-admin

Hello,

on my installation, sometimes it redirected to port 8080 when accessing http://mysite/wp-admin. I dont know why, but sometimes it redirect me to http://mysite:8080/wp-admin

it just quite annoying if we serve it at that port, but if somehow we need to disable varnish and use nginx at port 80 instead, it will give us error.

My fix is add:

port_in_redirect off;

at site configuration or even nginx.conf. I don't know whether it's a good idea or not, and why that happens.

If that's a good idea it seems we can add it to nginx.conf

Pages not cached and no login in woocommerce

Hello,

it seems like I can´t get this varnish,vcl to work.

Neither does it cache anything nor can I login via "my-account" on woocommerce.

Site is: https://ediyemade.com if anyone want to take a look. I´m sadly not familar with varnish so no idea why it does not work ;( (using the default.vcl offereded here)

thanks guys.

Edit: Found a nice plugin, it is called smart varnish (very smart indeed lol) made config a whole lot easier. ) Cache is working now, but no login via "my-account" possible. While I can login via wp-login.

What do I miss?

can't access to my admin ....

hi !

i using varnish 4.0 and Wordpress 4.1
i like your job it's awesome cache.
but i have a problem to enter my admin area:

mywebsite.com/s-login

or another website:

mywebsite.com/tomer-login

he said :
" You must log in to access the admin area. "
and i am the admin , i don't how to fix that , before this Code of Default.vcl i was free access to my admin area without problem..

what i need to do to fix that ?

regards,
Tomer

Site Example Configuration l

Site example configuration is listening at port 80 too. It should be like that or else? (e.g 8080). I believe the second one.

Have a nice day.

Problem with Varnish returning empty page after login

Hi Nico !

Hi, I am using this config for a wordpress-woocommerce with mod_pagespeed, but something weird happens on when I try to log in or register a user. I have made sure the /my-account/ is not cached and that the POST request to send the data at login / register is not cached, actually it works. Users login and register, but after one of those actions, the server returns the same form page with the form being empty, while it should return the "my account" page with the data of the user logged in. Can you please shed some light ? How do you make varnish stop returning cached content once you hit a certain cookie or condition ?

Here is the pasta of my config : http://pastebin.com/3NnW0Sbp

Thanks !

Nginx fastcfi_params item deprecation

Since nginx 1.6.1-2 it seems that "fastcgi_params" has no more SCRIPT_FILENAME parameter.
https://github.com/nicolargo/varnish-nginx-wordpress/blob/master/nginx/global/php-fpm.conf#L12

I'm not sure if there is change that has to be made.

The nginx update log:

nginx-common (1.6.1-2) unstable; urgency=medium

  As of nginx-1.6.1-2 we have synced all configuration files with upstream and
  we plan to keep them in sync from now on.

  Unfortunately that might break existing configuration for some users. Please
  check the matrix below for more information:

  File            Changes
  -----------------------
  koi-win         whitespace
  koi-utf         whitespace
  mime-types      whitespace, changed js/rss mime type,
                  minor other changes & additions
  scgi_params     whitespace, added HTTPS
  uwsgi_params    whitespace, added HTTPS, removed UWSGI_SCHEME
  fastcgi_params  whitespace, removed SCRIPT_FILENAME
  fastcgi.conf    new upstream configuration file

  Fastcgi configuration issues
  ============================

  nginx shipped a modified `fastcgi_params`, which declared `SCRIPT_FILENAME`
  fastcgi_param. This line has now been removed. From now on we are also
  shipping fastcgi.conf from the upstream repository, which includes a sane
  `SCRIPT_FILENAME` parameter value.

  So, if you are using fastcgi_params, you can try switching to fastcgi.conf
  or manually set the relevant params.

  You might also want to read the documentation section before proceeding.

  http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html
  section: $fastcgi_script_name variable.

 -- Christos Trochalakis <[email protected]>  Thu, 28 Aug 2014 14:23:42 +0300

CXRF issues w/phpMyAdmin, Adminer, etc

It seems the tokens generated by phpMyAdmin, Adminer, and other database management tools (SQLBuddy) aren't properly handled with the VCL as it is right now. Since they're being generated on-demand (IIRC), the tokens aren't being updated and when you attempt to log-in, it prevents authorization and you're brought back to the log-in page; effectively preventing you from accessing / using a database management tool inside or outside of WordPress.

I tried modifying the VCL to allow them to pass, though I'm still tinkering with Varnish. Perhaps you know of a way around this? If you install Adminer (by itself, single PHP file), you should be able to replicate this easily. The same applies for Adminer as a WordPress plugin, SQLBuddy, and phpMyAdmin. I've not yet tested others.

The cart is empty

I used your varnish vcl for my Wooecommerce. The cart is empty whenever i add anything. I tried to disable ajax request but no luck. Here are my exeptions:

    ### REMOVE IT IF YOU DO NOT USE WOOCOMMERCE ###
    if (req.url ~ "/(cart|my-account|checkout|addons|/?(add-to-cart=|added-to-cart=))") {
            return (pass);
    }
    if (req.url ~ "/product/*$") {
            return (pass);
    }

     if ( req.url ~ "/?add-to-cart=" ) {
             return (pass);
     }
    if (req.http.X-Requested-With == "XMLHttpRequest") {
            return(pass);
    }

Duplicate APC Stat - apc.ini

Hey Nicolas,

Great work on the configuration - I'm using it on a test node right now and noticed that W3TC wasn't saving anything, despite previously working. Narrowing it down, it didn't stop until after APC was installed and apc.ini was added to /etc/php.d/.

There's a duplicate apc.stat = "0" in the apc.ini file. After dropping the duplicate, all was well again.

Keep up the great work!

  • Jonathan

Fail to login to wordpress

Hi,
Thank you for your great Varnish4 config, my frontend page run really fast but when I try to login to Wordpress at login page, it fail with this

Error 503 Backend fetch failed
Backend fetch failed
Guru Meditation:
XID: 32788
Varnish cache server

I use Nginx as backend server on port 8080 for HTTP request. Here is my Varnish log:
<< BeReq >> 32858

  • Begin bereq 32857 pass
  • Timestamp Start: 1440994979.525020 0.000000 0.000000
  • BereqMethod POST
  • BereqURL /wp-login.php
  • BereqProtocol HTTP/1.1
  • BereqHeader Host: exciter.com
  • BereqHeader Content-Length: 114
  • BereqHeader Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
  • BereqHeader Origin: http://exciter.com
  • BereqHeader User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36
  • BereqHeader Content-Type: application/x-www-form-urlencoded
  • BereqHeader Referer: http://exciter.com/wp-login.php?redirect_to=http%3A%2F%2Fexciter.com%2Fwp-admin%2F&reauth=1
  • BereqHeader Accept-Encoding: gzip, deflate
  • BereqHeader Accept-Language: en-US,en;q=0.8,vi;q=0.6
  • BereqHeader Cookie: PHPSESSID=rljmukr2iji6som9mcgsv9t1k7; _ga=GA1.2.1653772168.1440994312; woocommerce_cart_hash=null; wfvt_662187887=55e3d69164314; wordpress_test_cookie=WP+Cookie+check
  • BereqHeader Cache-Control: max-age=0
  • BereqHeader X-Forwarded-For: 222.222.217.191, 222.222.217.191
  • BereqHeader X-Varnish: 32858
  • VCL_call BACKEND_FETCH
  • VCL_return fetch
  • FetchError no backend connection
  • Timestamp Beresp: 1440994979.525360 0.000340 0.000340
  • Timestamp Error: 1440994979.525375 0.000355 0.000015
  • BerespProtocol HTTP/1.1
  • BerespStatus 503
  • BerespReason Service Unavailable
  • BerespReason Backend fetch failed
  • BerespHeader Date: Mon, 31 Aug 2015 04:22:59 GMT
  • BerespHeader Server: Varnish
  • VCL_call BACKEND_ERROR
  • BerespHeader Content-Type: text/html; charset=utf-8
  • BerespHeader Retry-After: 5
  • VCL_return deliver
  • Storage malloc Transient
  • ObjProtocol HTTP/1.1
  • ObjStatus 503
  • ObjReason Backend fetch failed
  • ObjHeader Date: Mon, 31 Aug 2015 04:22:59 GMT
  • ObjHeader Server: Varnish
  • ObjHeader Content-Type: text/html; charset=utf-8
  • ObjHeader Retry-After: 5
  • Length 282
  • BereqAcct 0 0 0 0 0 0
  • End

<< Request >> 32857

  • Begin req 32856 rxreq
  • Timestamp Start: 1440994979.524812 0.000000 0.000000
  • Timestamp Req: 1440994979.524812 0.000000 0.000000
  • ReqStart 222.222.217.191 53004
  • ReqMethod POST
  • ReqURL /wp-login.php
  • ReqProtocol HTTP/1.1
  • ReqHeader Host: exciter.com
  • ReqHeader Content-Length: 114
  • ReqHeader Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
  • ReqHeader Origin: http://exciter.com
  • ReqHeader User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36
  • ReqHeader Content-Type: application/x-www-form-urlencoded
  • ReqHeader Referer: http://exciter.com/wp-login.php?redirect_to=http%3A%2F%2Fexciter.com%2Fwp-admin%2F&reauth=1
  • ReqHeader Accept-Encoding: gzip, deflate
  • ReqHeader Accept-Language: en-US,en;q=0.8,vi;q=0.6
  • ReqHeader Cookie: PHPSESSID=rljmukr2iji6som9mcgsv9t1k7; _ga=GA1.2.1653772168.1440994312; woocommerce_cart_hash=null; wfvt_662187887=55e3d69164314; wordpress_test_cookie=WP+Cookie+check
  • ReqHeader Cache-Control: max-age=0
  • ReqHeader Connection: keep-alive
  • ReqHeader X-Forwarded-For: 222.222.217.191
  • VCL_call RECV
  • ReqUnset X-Forwarded-For: 222.222.217.191
  • ReqHeader X-Forwarded-For: 222.222.217.191, 222.222.217.191
  • VCL_return pass
  • VCL_call HASH
  • VCL_return lookup
  • VCL_call PASS
  • VCL_return fetch
  • Link bereq 32858 pass
  • Timestamp Fetch: 1440994979.525510 0.000697 0.000697
  • Timestamp ReqBody: 1440994979.525573 0.000761 0.000064
  • RespProtocol HTTP/1.1
  • RespStatus 503
  • RespReason Backend fetch failed
  • RespHeader Date: Mon, 31 Aug 2015 04:22:59 GMT
  • RespHeader Server: Varnish
  • RespHeader Content-Type: text/html; charset=utf-8
  • RespHeader Retry-After: 5
  • RespHeader X-Varnish: 32857
  • RespHeader Age: 0
  • RespHeader Via: 1.1 varnish-v4
  • VCL_call DELIVER
  • RespUnset Server: Varnish
  • RespUnset X-Varnish: 32857
  • RespUnset Via: 1.1 varnish-v4
  • RespHeader X-Cache: MISS
  • VCL_return deliver
  • Timestamp Process: 1440994979.525592 0.000780 0.000019
  • RespHeader Content-Length: 282
  • Debug "RES_MODE 2"
  • RespHeader Connection: keep-alive
  • Timestamp Resp: 1440994979.525638 0.000825 0.000046
  • Debug "XXX REF 1"
  • ReqAcct 752 114 866 198 282 480
  • End

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.