Skip to content

Instantly share code, notes, and snippets.

@iamdylanngo
Created April 19, 2020 15:19
Show Gist options
  • Save iamdylanngo/f0d59d9941d24559a1cb1ebce44acd30 to your computer and use it in GitHub Desktop.
Save iamdylanngo/f0d59d9941d24559a1cb1ebce44acd30 to your computer and use it in GitHub Desktop.
apache-with-varnish-cache.txt
1, Config varnish cache
Example varnish cache config:
vim /etc/varnish/default.vcl
vcl 4.0;
# Default backend definition. Set this to point to your content server.
backend default {
.host = "127.0.0.1";
.port = "8080";
}
sub vcl_recv {
# Happens before we check if we have this in cache already.
#
# Typically you clean up the request here, removing cookies you don't need,
# rewriting the request, etc.
}
sub vcl_backend_response {
# Happens after we have read the response headers from the backend.
#
# Here you clean the response headers, removing silly Set-Cookie headers
# and other mistakes your backend does.
}
sub vcl_deliver {
# Happens when we have all the pieces we need, and are about to send the
# response to the client.
#
# You can do accounting or modifying the final object here.
}
2, Config apache: http, https
Go to apache config file:
<virtualHost *:8080>
ServerAdmin [email protected]
DocumentRoot /var/www/magento/current/
ServerName m234cc.local
ServerAlias www.m234cc.local
<Directory /var/www/magento/current/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/www/m234cc-error.log
CustomLog /var/www/m234cc-access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerName m234cc.local
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:80/
RequestHeader set X-Forwarded-Port "443"
RequestHeader set X-Forwarded-Proto "https"
SSLEngine On
SSLCertificateFile /var/www/ssl/server_crt.pem
SSLCertificateKeyFile /var/www/ssl/server_key.pem
# SSLCertificateChainFile /etc/apache2/ssl/example.com.chain
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment