Skip to content

Instantly share code, notes, and snippets.

@jackc
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackc/8be78e1d5037898d75f5 to your computer and use it in GitHub Desktop.
Save jackc/8be78e1d5037898d75f5 to your computer and use it in GitHub Desktop.
apache config for The Pithy Reader
<VirtualHost 162.243.221.160:80>
ServerName tpr.example.com
Redirect permanent / https://tpr.example.com/
</VirtualHost>
<VirtualHost 162.243.221.160:443>
ServerName tpr.example.com
SSLEngine On
SSLCertificateFile /etc/ssl/certs/tpr.example.com.crt
SSLCertificateKeyFile /etc/ssl/private/tpr.example.com.key
SSLCACertificateFile /etc/ssl/certs/tpr.example.com.cer
ProxyRequests off
ProxyPass /api http://127.0.0.1:4000/api
ProxyPassReverse /api http://127.0.0.1:4000/api
# Compress API responses
<Location /api>
SetOutputFilter DEFLATE
</Location>
DocumentRoot /usr/share/tpr/assets
<Directory /usr/share/tpr/assets>
RewriteEngine On
Order Allow,Deny
Allow from all
AllowOverride None
Options FollowSymLinks
AddDefaultCharset utf-8
# Cache assets for 30 days
<FilesMatch "\.(css|js)(\.gz)?$">
Header set Cache-Control "max-age=2592000, public"
</FilesMatch>
# Always require validating HTML
<FilesMatch "\.html(\.gz)?$">
Header set Cache-Control "max-age=0, must-revalidate"
</FilesMatch>
# Serve pre-compressed assets
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteRule ^(.*)\.css $1\.css\.gz [QSA]
RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1]
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteRule ^(.*)\.js $1\.js\.gz [QSA]
RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1]
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteRule ^(.*)\.html $1\.html\.gz [QSA]
RewriteRule \.html\.gz$ - [T=text/html,E=no-gzip:1]
# Set Content-Encoding on the files we told mod_deflate not to gzip
Header set Content-Encoding gzip env=no-gzip
</Directory>
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment