Sometimes you need to quickly setup Varnish, usually in an emergency (like, your website got featured on Reddit’s frontpage 😀 ), to quickly absorb most of the hits hitting your website.
But the webserver is already using port 80.
Now what ?
Pretty easy actually :
- Setup Varnish on other port, say, 6081
- Run an iptables command : to forward incoming traffic from port 80 to port 6081
- Make sure Varnish uses 127.0.0.1:80 as the backend
Presto – now all the traffic hits Varnish first – which will process them in lightning speed.
Alright, so here’s the gory detail, also available on Pastebin.com : https://pastebin.com/2UBD7s05
Enjoy !
========
apt-get update ; apt-get -y install varnish
# Varnish should be already configured to list on port 6081
# if in doubt, check /etc/default/varnish,
# and look for the following line :
# DAEMON_OPTS="-a :6081
# edit varnish config
vi /etc/varnish/default.vcl
# make sure the .port line is set to 80, like this :
# .port = "80";
# then save & exit
# enable Apache's expires & headers module
a2enmod expires
a2enmod headers
# setup caching for static files
# via .htaccess file
echo "Header unset ETag" >> /var/www/.htaccess
echo "FileETag None" >> /var/www/.htaccess
echo "<ifmodule mod_expires.c>" >> /var/www/.htaccess
echo "<filesmatch \"(?i)^.*\\.(ico|flv|jpg|jpeg|png|gif|js|css)$\">" >> /var/www/.htaccess
echo "ExpiresActive On" >> /var/www/.htaccess
echo "ExpiresDefault \"access plus 2 minute\"" >> /var/www/.htaccess
echo "</filesmatch>" >> /var/www/.htaccess
echo "</ifmodule>" >> /var/www/.htaccess
# enable caching in php.ini
vi /etc/php/7.0/apache2/php.ini
# make sure session.cache_limiter = public
# save & exit
# restart Apache
/etc/init.d/apache2 restart
###### now let's start forwarding traffic to Varnish ######
# enable port forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
vi /etc/sysctl.conf
# add this line at the end of the file :
# net.ipv4.ip_forward = 1
# now here's the command that will actually forward the traffic from port 80 to Varnish
# change eth0 to your computer's network interface name
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 6081
# make sure this iptables setting will become permanent
apt-get -y install iptables-persistent
Now here’s the command that will actually forward the traffic from port 80 to Varnish.
รับทำเว็บไซต์ เชียงใหม่
This entry was posted on Sunday, February 18th.
รับà¸à¸à¸à¹à¸šà¸š สติ๊à¸à¹€à¸à¸à¸£à¹Œà¹„ลน์
beneran membuat kepala pening
memusingkan kepala aing
wow keren .nice
lieur bray euy
Cool bro, i will follow step by step your instruction
Thanks for your info
Felix Andika
Terima kasih infonya bos, sangat membantu sekali
Informasi yang menarik,, banyak pengetahuan yang dapat dipelajari di website ini..
You have remarked very interesting details ! ps nice site.
I beloved up to you’ll obtain performed proper here. The caricature is tasteful, your authored subject matter stylish. nevertheless, you command get bought an edginess over that you would like be delivering the following. sick indisputably come more in the past again since exactly the similar just about very often inside of case you shield this hike.
Heya! I’m at work browsing your blog from my new iphone 4! Just wanted to say I love reading your blog and look forward to all your posts! Carry on the superb work!
Thank you for sharing your idea. It’s great:D
Nice post. I was checking constantly this weblog and I’m inspired!
Thank you so much for the info that you have to say, because there inforamasi which provide very useful
thnaks for all this formation is awsome
Nice info. This is a very impressive post, Very useful information, it clarified things a lot for us. Thanks for sharing valuable tips. – Shirdi Flight packages from Chennai
keren broo
https://kriptova.com
I found this post as very useful , you have tried to explain things very beautifully . Keep up the good job.
Thanks
DedicatedHosting4u.com
nice post lads Thank for ur post
To the sufehmi.com admin, Thanks for the well-researched post!
To the sufehmi.com administrator, Your posts are always well-written and engaging.
To the sufehmi.com webmaster, Thanks for sharing your thoughts!
Dear sufehmi.com webmaster, Your posts are always interesting.
Hi sufehmi.com owner, Thanks for the well-structured and well-presented post!
To the sufehmi.com administrator, Your posts are always informative and well-explained.
Dear sufehmi.com admin, You always provide key takeaways and summaries.
Hi sufehmi.com webmaster, Your posts are always well-supported by research and data.
Hi sufehmi.com administrator, You always provide clear explanations and step-by-step instructions.
To the sufehmi.com webmaster, Your posts are always well-referenced and credible.
Hi sufehmi.com owner, Your posts are always well-structured and logical.
Hello sufehmi.com owner, You always provide helpful diagrams and illustrations.
Dear sufehmi.com administrator, You always provide clear explanations and step-by-step instructions.
To the sufehmi.com owner, Thanks for the well-researched and well-written post!
Hello sufehmi.com admin, Thanks for the well-organized and comprehensive post!
To the sufehmi.com admin, Thanks for the well-structured and well-presented post!
Dear sufehmi.com administrator, Thanks for the well-researched and well-written post!
Dear sufehmi.com admin, You always provide great examples and real-world applications, thank you for your valuable contributions.
Hello sufehmi.com owner, Good job!
Dear sufehmi.com administrator, Your posts are always well received by the community.
Hello sufehmi.com owner, You always provide great examples and real-world applications.
Hello sufehmi.com administrator, You always provide great examples and real-world applications.
Hi sufehmi.com admin, You always provide helpful diagrams and illustrations.
Hi sufehmi.com webmaster, Thanks for the well-organized post!
Dear sufehmi.com webmaster, Your posts are always interesting.
To the sufehmi.com administrator, Thanks for the in-depth post!
Hello sufehmi.com admin, Thanks for the well-researched and well-written post!
Hi sufehmi.com admin, Your posts are always well researched.
Hi sufehmi.com admin, Thanks for the informative and well-written post!
Dear sufehmi.com webmaster, You always provide clear explanations and definitions.
Howdy, i read your blog from time to time and i own a similar
one and i was just curious if you get a lot of spam responses?
If so how do you stop it, any plugin or anything you can advise?
I get so much lately it’s driving me crazy so any assistance is very
much appreciated.
In order to improve your standard of living or develop in the international IT arena, I recommend that you visit this website, where you will find all the necessary information about employment and a huge number of completely different vacancies. And all this is available in just a couple of clicks, so I definitely recommend it!
I think the admin of this site is in fact working hard in support of his web page, as here every stuff
is quality based information.
Hello there, I found your blog by the use
of Google at the same time as searching for a similar subject, your website came up, it looks good.
I’ve bookmarked it in my google bookmarks.
Hi there, simply changed into alert to your weblog thru Google, and located that it
is really informative. I am gonna watch out for brussels.
I will appreciate for those who continue this in future.
Numerous people will probably be benefited from your writing.
Cheers!
What ? data of un-ambiguity ?nd preserveness of precious experience ?bout unpredicted emotions.
Feell free t? visit my blog best university mexico
Inspiring story t?ere. What occurred aft?r?
Thanks!
My web-site; entra verified id
Thiis text ?s priceless. W?ere c?n I find ?ut more?
Al?? visit myy web pa?e; rwg trusted dealers
Excellent go?ds f?om y?u, man. ? hav? have in mind yo?r
stuff prior t? ?nd you’r? just to? g?eat. I ?ctually ?ike wh?t you have bought ?ight here,
ce?tainly ?ike what ??u are sayin and the w?y in wh?ch during wh?ch yo? ar? ?aying it.
Yoou ma?e it entertaining aand ?ou still tak? care of to stay it smart.
? c?n not wait t? rea? f?r more from you. This
is a?tually ? tremendous website.
My blog post; verified logo copy and paste
?t’s ?oing t? be end of m?ne day, exceept beefore endinbg I am reaading
th?s wonderful paragraph to increase my kno?-how.
Also visit my page :: 3 to 5 trusted contacts facebook
Unquestionably believe that which you said. Your favorite justification seemed
to be on the net the easiest thing to be aware of.
I say to you, I definitely get irked while people consider worries that they just don’t know about.
You managed to hit the nail upon the top and defined out the whole
thing without having side-effects , people can take a signal.
Will probably be back to get more. Thanks
What’s ?p friends, how is ev?rything, ?nd what you w?sh f?r to say ?n t??
topic ?f this piece of writing, in m? v?ew iits in f?ct
remarkable in support of m?.
my webpage: discuss
I wa? suggestedd thjs web site ?? my cousin. ?’m not sure whet?er t?is post is w?itten byy him as no one e?se ?no? ?uch detailed ?bout myy
probl?m. ?ou’re incredible! ?hanks!
m? site :: check ?? ????? ?? ?????
I’m impressed, I have to admit. Seldom do I encounter a blog that’s both equally
educative and amusing, and without a doubt, you’ve hit the nail on the head.
The issue is something too few folks are speaking intelligently about.
I am very happy I came across this in my search for something relating to this.
Good post. I learn something totally new and challenging on sites I stumbleupon every day.
It’s always interesting to read articles from other authors and
practice a little something from other sites.
Yes! Finally something about slot online.
I connstantly spent m? half ann houhr to re?d t??? webpage’s articles ?ll t?e
t?me a?ong with ? mug of coffee.
He?e i? my web page :: check ?? ?????? ????? ?? ?????? ???? (Merle)
If yo? desire to improve y?ur familiarity ?nly keep visiting t??s website
and ?e updated w?t? th? mo?t rec?nt news posted ?ere.
A?so visit mmy website: Source
Hey! I know this iis sort ?f off-topic but I nee?ed to ask.
Does building a well-established blog ?uch
a? ??urs require ? massive am?unt work? Iam c?mpletely new to operating a
blog ?owever I do write in my diaqry daily. ?’d li?e to start
? blog ?o I can easily share my own experience and
felings online. Plea?e let m? know if yo? have any suggestions or tips for ne? aspiring
blog owners. Thankyou!
m? website: weblink
Thank you for any other great article. Where else could
anybody get that kind of info in such a perfect method of writing?
I’ve a presentation next week, and I’m on the
look for such info.
Amazing blog! ?o you have anny tips ?nd
hints for aspiring writers? ?’m hoping to start m? own blog son but
I’m a ?ittle lost ?n ever?thing. Would you propose starting
?ith a free platform ?ike WordPress or go for a
paid option? The?e are so many choices out t?ere thnat I’m complet?ly overwhelmed ..
Any ideas? App?eciate it!
?ere ?s my blog post … ?????
?ust wish too say ylur rticle ?s as astonishing.
?he clarity ?n you? postt i? simply excellent ?nd i can assume yyou ?re an expert
?n t?is subject. Well ?ith your permission all?w me
to grab ?ou? feesd to ke?p up to ?ate ?ith forthcoming post.
?hanks ? million and pl?ase carry on t?? rewarding work.
Take a ?ook att m? pag? read here