Un tips rapide en anglais, parce que disponible nul part en ligne…
So you have a website behind Varnish that uses AJAX XMLHTTPRequest and by using a set of DNS redirection you are actually in a cross domain configuration ? Well, I know, it’s a pain in the ass…
For GET requests, it’s pretty easy, you have a nice solution here : https://www.varnish-cache.org/trac/ticket/541. Now if you use AJAX POST request, it a bit different, you will get a 503 Guru Meditation. In fact, by default Varnish will “pass” the request. It means that Varnish will send the request by default to the backend(s) and when will then receive the answer. The problem is that the answer will not be understood by Varnish and you will end up with a “FetchError c http format error”.
The solution wil be to change this default behavior from pass to “pipe”. In the configuration, Varnish will just stream bytes from the client to the backend back and forth directly without any manipulation. To do so, here is the configuration to put in your vcl_recv :
#matching all the AJAX XMLHTTPRequest form my site if (req.http.host ~ "(?i)^www.site.com$" && req.http.X-Requested-With == "XMLHttpRequest" ) { #Rewrite the header if needed set req.http.host = "backends.site.com"; #Setting the backend to forward to set req.backend = backends_servers; #Setting the pipe mode return(pipe); } |
Here you go ! I hope you liked it…
Read More
On a une infra haute dispo, mais pas encore vraiment haute perf. Pour y passer, on va utiliser Varnish qui mettra en cache les pages de notre site ! Ce n’était pas prévu au planning initial que j’ai posé une nuit très tard… Mais c’est un MUST ! Varnish sera situé entre le load balancer et les frontaux (qu’il...
On continu d’avancer et on touche presque à la fin. A la fin de ce tuto, on aura une plateforme web fonctionnelle. Aujourd’hui nous allons mettre en place le load balancer HAPROXY qui aura pour objectif de répartir la charge entre les deux frontaux web installés mais aussi stunnel qui s’occupera de gérer la couche SSL...
Poursuivons le Summer Camp qui devient plus au Autumn Camp… Après la mise en réplication de nos bases de données, on va mettre en place le slipt Read/Write sur nos bases. La base maitre servira pour l’écriture de données et la base slave pour la lecture. Il est à noter que l’on peut ajouter autant e slave que l’on...
Derniers Commentaires