Setup Varnish on Port 80

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 :

  1. Setup Varnish on other port, say, 6081
  2. Run an iptables command : to forward incoming traffic from port 80 to port 6081
  3. 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

76 thoughts on “Setup Varnish on Port 80

  1. 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.

  2. 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!

  3. Thank you so much for the info that you have to say, because there inforamasi which provide very useful

  4. 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

  5. Dear sufehmi.com admin, You always provide great examples and real-world applications, thank you for your valuable contributions.

  6. 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.

  7. 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!

  8. 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.

  9. 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!

  10. 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

  11. 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

  12. 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

  13. 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.

  14. 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.

  15. 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)

  16. 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

  17. 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

  18. 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.

  19. 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 … ?????

  20. ?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

  21. Hello everyone, it’s my first pay a visit at this web page, and article is actually fruitful
    in favor of me, keep up posting these types of posts.

  22. It’s amazing in support of me to have a web site, which is beneficial in support of my know-how.
    thanks admin

  23. Do you want to give your roof a rejuvenation? Shingle
    Magic Roof Sealer is what you need. The exceptional product provides an unparalleled degree of care for your asphalt shingles, making sure they remain durable.

    With Shingle Magic Roof Sealer, you’re not just applying any
    ordinary product. You’re selecting a high-end roof rejuvenation solution designed to greatly prolong the life of your roof for many years to come.
    It’s a smart choice for those looking to protect their
    investment.

    What makes Shingle Magic Roof Sealer? To begin with, its exclusive formula
    penetrates the asphalt shingles, reviving their initial strength and aesthetic.
    Moreover, the sealer is incredibly easy to apply, requiring no effort for optimal results.

    Not only does Shingle Magic Roof Sealer increase
    the life of your roof, but it offers superior defense against environmental
    damage. Be it harsh sunlight, rainstorms, or freezing temperatures, it remains well-protected.

    Furthermore, selecting Shingle Magic Roof Sealer indicates you’re opting for an green option. Its non-toxic makeup means
    little environmental impact, which makes it a conscious choice for the planet.

    In conclusion, Shingle Magic Roof Sealer excels
    as the ultimate roof rejuvenation solution. Its ability to prolong the life of your
    roof but also delivering exceptional protection and an environmentally friendly option makes Shingle Magic as the
    ideal choice for property owners looking to care for their property’s
    future.

    Moreover, a significant advantage of Shingle Magic Roof Sealer is its affordability.
    Instead of spending heaps of money on frequent repairs or a full roof replacement, choosing Shingle Magic can save you expenses in the long run.
    This makes it a budget-friendly option that provides premium results.

    Furthermore, the simplicity of its application of
    Shingle Magic Roof Sealer is noteworthy. You don’t need
    specialized knowledge to apply it. Whether you’re a DIY enthusiast or prefer for expert application, Shingle Magic provides a
    straightforward process with excellent results.

    Shingle Magic’s lasting power is yet another significant reason to choose it.
    After application, it forms a layer that preserves the integrity of your shingles for a
    long time. This means fewer concerns about weather
    damage and a more secure feeling about the state of your roof.

    When it comes to aesthetic appeal, Shingle Magic Roof Sealer also stands
    out. Not only does it safeguard your roof but also improves its appearance.
    The shingles will appear newer, adding curb appeal and value to your property.

    Customer satisfaction with Shingle Magic Roof Sealer is another testament
    to its quality. Many customers have reported remarkable improvements in their roof’s condition after using the product.
    Reviews emphasize its simplicity, durability, and superior protective qualities.

    Finally, selecting Shingle Magic Roof Sealer means choosing a trusted solution for roof
    rejuvenation. With its blend of sturdiness, visual appeal,
    cost-effectiveness, and simplicity positions it as
    the perfect choice for homeowners seeking to enhance the life and appearance
    of their roof. Act now to give your roof the care it deserves
    with Shingle Magic Roof Sealer.

  24. Nice blog here! Also your site loads up fast! What host are you using? Can I get your affiliate link to your host? I wish my web site loaded up as quickly as yours lol

  25. Freedman’s Office Furniture: Crafting Workspaces in Orlando

    **Elevate Your Workspace in Orlando with Freedman’s Office Furniture**

    In the heart of Orlando, Freedman’s Office Furniture emerges as
    the go-to destination for all your office furnishing needs.

    Our showroom at 200 E Robinson St Suite 1120 caters to discerning customers in neighborhoods like
    Audubon Park and Baldwin Park, delivering top-notch office furniture solutions.

    **Orlando: A Hub of Innovation and Productivity**

    Founded in 1875, Orlando pulsates with innovation, mirroring Freedman’s commitment
    to crafting workspaces that inspire. With a population of 309,154 (2021) and 122,607 households,
    Orlando’s dynamic environment finds resonance in Freedman’s diverse range of ergonomic
    office chairs and modern office seating solutions.

    **Navigating Orlando’s Pulse: Interstate 4**

    Orlando’s lifeblood, Interstate 4, threads through the city,
    connecting its vibrant neighborhoods. Likewise, Freedman’s Office Furniture weaves a tapestry of convenience,
    delivering quality office furniture to every corner of Orlando.
    Our commitment aligns with the city’s ethos of seamless
    connectivity and accessibility.

    **Crafting Comfort: Office Chairs Tailored to Orlando’s Needs**

    Considering Orlando’s diverse weather, ranging from warm summers to mild winters, investing in quality office furniture is a wise decision. Freedman’s Office
    Furniture provides not just chairs but ergonomic solutions that adapt to Orlando’s
    varied temperatures, ensuring comfort year-round.

    **Orlando’s Landmarks and Freedman’s Touch**

    Explore Orlando’s iconic points of interest like ICON Park and Antarctica: Empire of the Penguin,
    mirroring the uniqueness that Freedman’s brings to office spaces.
    Here are five facts about some of Orlando’s landmarks:

    – **7D Motion Theater Ride At ICON Park:** An immersive
    experience with seven dimensions of excitement.

    – **America’s Escape Game Orlando:** Orlando’s premier escape room destination.
    – **Aquatica Orlando:** A water park blending marine life with thrilling water rides.

    – **Chocolate Kingdom – Factory Adventure Tour:** Unraveling the mysteries of chocolate production.
    – **Discovery Cove:** An all-inclusive day resort featuring marine life encounters.

    **Why Choose Freedman’s in Orlando**

    Selecting Freedman’s Office Furniture in Orlando is an investment in quality, style, and ergonomic excellence.
    Our vast range of office chairs, including ergonomic options, executive seating, and contemporary designs,
    ensures that your workspace mirrors Orlando’s vibrancy and innovation. Choose Freedman’s
    for a workplace that aligns with the dynamic spirit of Orlando.


    “Elevate Your Workspace with Freedman’s Office
    Desks in Orlando

    **Discover the Essence of Productivity: Freedman’s Office Desks in Orlando**

    When it comes to crafting the perfect workspace in Orlando, Freedman’s
    Office Furniture stands out as the epitome of excellence.
    Located at 200 E Robinson St Suite 1120, our showroom
    caters to neighborhoods such as Audubon Park and Baldwin Park, providing a diverse range of office desks that redefine functionality and style.

    **Orlando: A Tapestry of Diversity and Innovation**

    Established in 1875, Orlando boasts a rich history steeped in diversity and innovation. With
    a current population of 309,154 (2021) and 122,607 households, Orlando’s
    dynamic landscape finds a reflection in Freedman’s commitment to delivering top-tier office desks
    designed for the city’s progressive work environment.

    **Navigating Orlando’s Pulse: Interstate 4**

    Much like the seamless flow of traffic on Interstate 4, Freedman’s Office
    Furniture ensures a smooth journey in furnishing your workspace.
    We bring quality office desks to every corner of Orlando,
    mirroring the city’s commitment to accessibility and connectivity.

    **Crafting Efficiency: Office Desks Tailored to Orlando’s Work Culture**

    In a city where work meets play, investing in a workspace that
    reflects efficiency and style is crucial. Freedman’s Office Desks go beyond functionality; they are
    a statement of professionalism and innovation, aligning perfectly with Orlando’s ethos.

    **Orlando’s Landmarks and Freedman’s Craftsmanship**

    Explore Orlando’s iconic landmarks and witness the craftsmanship
    that Freedman’s brings to office spaces. Here are five facts about some of Orlando’s beloved destinations:

    – **Caro-Seuss-el:** A whimsical carousel inspired by Dr.
    Seuss’s imaginative world.
    – **Chocolate Kingdom – Factory Adventure Tour:** An interactive journey through
    the art of chocolate making.
    – **Crayola Experience Orlando:** A colorful adventure
    where creativity knows no bounds.
    – **Dezerland Park Orlando:** An entertainment hub featuring go-karts, bowling, and
    arcade games.
    – **Discovery Cove:** An immersive marine experience allowing guests to swim with
    dolphins.

    **Why Choose Freedman’s Office Desks in Orlando**

    Selecting Freedman’s Office Desks in Orlando is a testament to your
    commitment to a workspace that exudes professionalism and sophistication. Our range of office desks, including executive desks,
    modern designs, and collaborative workstations, ensures that your
    workspace reflects the dynamic spirit of Orlando.
    Choose Freedman’s for desks that elevate your work environment.


    “Seating Solutions for Success: Freedman’s Office Chairs in Orlando

    **Experience Unparalleled Comfort: Freedman’s Office
    Chairs in Orlando**

    In the heart of Orlando, where comfort meets productivity, Freedman’s Office Furniture takes pride in presenting
    a premium collection of office chairs. Nestled at 200 E Robinson St Suite
    1120, our showroom extends its reach to neighborhoods like
    Clear Lake and College Park, providing an extensive range of
    office chairs that redefine ergonomic excellence.

    **Orlando: Where Innovation Meets Tradition**

    With a founding year of 1875, Orlando is a city that beautifully balances innovation and tradition.
    Boasting a population of 309,154 (2021) and 122,607 households, Orlando’s diversity and growth parallel Freedman’s
    commitment to delivering top-notch office chairs suited for the city’s evolving work culture.

    **Navigating Orlando’s Hub: Interstate 4**

    Much like the seamless flow of traffic on Interstate 4, Freedman’s Office Furniture ensures a smooth journey in offering quality office chairs to every
    office and workspace in Orlando, aligning
    with the city’s emphasis on accessibility and connectivity.

    **Elevating Your Workstation: Orlando’s Professionalism Embodied**

    In a city known for its professionalism and innovation, choosing
    the right office chair is essential. Freedman’s Office Chairs not only prioritize ergonomic design but also serve as a testament to
    your commitment to creating a workspace that mirrors Orlando’s ethos.

    **Orlando’s Gems and Freedman’s Seating Elegance**

    Explore the richness of Orlando’s landmarks
    while experiencing the elegance of Freedman’s Office Chairs.
    Here are five interesting facts about some
    of Orlando’s beloved destinations:

    – **Dolphin Nursery:** A heartwarming space at SeaWorld Orlando dedicated to nurturing newborn dolphins.

    – **DreamWorks Destination:** An immersive experience at Universal Studios Florida featuring characters from DreamWorks Animation.
    – **Fun Spot America Theme Parks:** A family-friendly amusement
    park with thrilling rides and attractions.

    – **Gatorland:** Known as the “”Alligator Capital of the World,”” Gatorland offers exciting wildlife shows.

    – **Harry Potter and the Escape from Gringotts:** A cutting-edge, multi-dimensional thrill ride
    at Universal Studios Florida.

    **Why Opt for Freedman’s Office Chairs in Orlando**

    Choosing Freedman’s Office Chairs in Orlando is an investment in your
    well-being and work satisfaction. Our diverse range of ergonomic chairs, including executive chairs, mesh back chairs,
    and swivel chairs, ensures that your workspace in Orlando is synonymous with comfort and style.
    Elevate your seating experience with Freedman’s for a workplace
    that inspires success.

    “Enhancing Workspaces: Freedman’s Ergonomic Office Furniture in Orlando

    **Discover the Art of Productivity: Freedman’s Ergonomic
    Office Furniture in Orlando**

    In the vibrant city of Orlando, where productivity
    meets innovation, Freedman’s Office Furniture proudly presents a curated selection of ergonomic office furniture.
    Conveniently located at 200 E Robinson St Suite 1120, our
    showroom caters to neighborhoods like Colonial Town Center and Colonialtown North, offering a diverse range of office solutions designed
    to elevate your workspace.

    **The Essence of Orlando’s Business Culture**

    Founded in 1875, Orlando stands as a testament to
    a harmonious blend of history and forward-thinking.

    Boasting a population of 309,154 (2021) and 122,607 households,
    Orlando’s dynamic business culture aligns seamlessly with Freedman’s commitment
    to providing cutting-edge ergonomic office furniture.

    **Navigating the Hub of Opportunities: Interstate 4**

    Much like the interconnected web of Interstate 4, Freedman’s Ergonomic Office Furniture ensures a
    smooth transition to a more comfortable and efficient
    workspace, symbolizing the city’s emphasis on progress and
    growth.

    **Investing in Comfort: A Smart Choice for Orlando Businesses**

    In a city that values innovation and efficiency, choosing ergonomic office furniture is a strategic
    investment. Freedman’s collection not only prioritizes functionality and comfort but also aligns with Orlando’s commitment to
    creating workspaces that inspire creativity and collaboration.

    **Orlando’s Landmarks and the Comfort of Freedman’s Furniture**

    Embark on a journey through Orlando’s iconic landmarks while experiencing the unmatched comfort of Freedman’s Ergonomic Office Furniture.

    Here are five fascinating facts about some of Orlando’s cherished
    destinations:

    – **Aquatica Orlando:** A thrilling waterpark
    owned and operated by SeaWorld Parks & Entertainment.

    – **Caro-Seuss-el:** A whimsical carousel in Seuss Landing at Universal’s Islands of Adventure.

    – **Dezerland Park Orlando:** Home to an extensive collection of classic cars and interactive exhibits.

    – **Discovery Cove:** An all-inclusive day resort where guests can swim with dolphins and explore
    coral reefs.
    – **Crayola Experience Orlando:** A colorful attraction at The Florida Mall offering hands-on creative activities.

    **Why Choose Freedman’s Ergonomic Office Furniture in Orlando**

    Opting for Freedman’s Ergonomic Office Furniture
    in Orlando is a commitment to a more productive and comfortable work environment.
    Our range of modern office solutions, including adjustable chairs, contemporary desks, and ergonomic accessories, ensures that your workspace reflects the dynamic spirit of Orlando, fostering creativity and success.


    “Elevating Workspace Aesthetics: Freedman’s Modern Office
    Chairs in Orlando

    **Indulge in Comfort: Freedman’s Modern Office Chairs Unveiled in Orlando**

    Nestled in the heart of Orlando, Freedman’s Office Furniture takes pride in introducing its exclusive collection of modern office chairs.
    Situated at 200 E Robinson St Suite 1120, our showroom caters to discerning customers in neighborhoods like Bryn Mawr and Catalina, offering
    a diverse range of seating solutions that combine style and functionality.

    **Orlando’s Thriving Legacy and Freedman’s Modern Elegance**

    Established in 1875, Orlando has grown into a dynamic city
    with a population of 309,154 (2021) and 122,607
    households. Freedman’s commitment to providing modern office
    chairs aligns seamlessly with Orlando’s legacy of progress, innovation, and a commitment to creating inspiring
    workspaces.

    **Navigating the Hub of Opportunities: Interstate 4**

    Much like the fluidity of Interstate 4, Freedman’s Modern Office Chairs symbolize a seamless blend of form and function.
    This reflects Orlando’s dedication to providing a conducive environment for businesses to thrive and individuals to excel.

    **Investing in Style: A Wise Choice for Orlando’s Professionals**

    In a city that values aesthetics and innovation, opting for Freedman’s Modern Office Chairs is a statement of sophistication. Our collection not only enhances the visual
    appeal of your workspace but also complements Orlando’s
    commitment to creating a work environment that fosters creativity
    and success.

    **Orlando’s Landmarks and the Style of Freedman’s Chairs**

    Embark on a journey through Orlando’s iconic landmarks
    while experiencing the unmatched style of Freedman’s Modern Office Chairs.
    Here are five fascinating facts about some of Orlando’s cherished destinations:

    – **Harry Potter and the Escape from Gringotts:** A cutting-edge, multi-dimensional thrill ride at
    Universal Studios Florida.
    – **Crayola Experience Orlando:** A colorful attraction at The Florida Mall offering hands-on creative activities.

    – **Dolphin Nursery:** A heartwarming exhibit at SeaWorld Orlando where guests
    can witness the beauty of dolphin life.
    – **Dezerland Park Orlando:** Home to an extensive collection of classic cars
    and interactive exhibits.
    – **Camp Jurassic:** An adventurous play area in Universal’s Islands of Adventure, inviting visitors to explore a prehistoric world.

    **Why Choose Freedman’s Modern Office Chairs in Orlando**

    Opting for Freedman’s Modern Office Chairs in Orlando is
    not just a choice; it’s a commitment to elevate your workspace.
    Our stylish and comfortable chairs ensure that your office reflects the vibrant and dynamic spirit
    of Orlando, making it an ideal place for productivity, innovation, and success.

Leave a Reply

Your email address will not be published. Required fields are marked *