Last active
June 11, 2016 22:03
-
-
Save iamkingsleyf/84a8d9f9d91cce379bd7 to your computer and use it in GitHub Desktop.
nginx hhvm configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# 301 redirect conf | |
## | |
server { | |
listen 80; | |
server_name www.citymp3.xyz; | |
rewrite ^(.*) http://citymp3.xyz$1 permanent; | |
} | |
## | |
# Main site config | |
## | |
server { | |
listen 80; | |
server_name citymp3.xyz; | |
## | |
# The magic; HHVM conf | |
## | |
include hhvm.conf; | |
## | |
# Logging details | |
## | |
access_log /srv/www/citymp3/logs/access.log; | |
error_log /srv/www/citymp3/logs/error.log error; | |
## | |
# Web root | |
## | |
root /srv/www/citymp3/public; | |
## | |
# Files to serve | |
## | |
index index.php index.html; | |
## | |
# Redirect server error pages to the static page /50x.html | |
## | |
#error_page 500 502 503 504 /50x.html; | |
#location = /50x.html { | |
#root /usr/share/nginx/html; | |
#} | |
## | |
# Feedburner redirect | |
## | |
if ($http_user_agent !~ FeedBurner) { | |
rewrite ^/feed/ http://feeds.feedburner.com/citymp3 last; | |
} | |
## | |
# Add a slash at the end of request */wp-admin | |
## | |
rewrite /wp-admin$ $scheme://$host$uri/ permanent; | |
## | |
# Yoast sitemap | |
## | |
location ~ ([^/]*)sitemap(.*)\.x(m|s)l$ { | |
## this redirects sitemap.xml to /sitemap_index.xml | |
rewrite ^/sitemap\.xml$ /sitemap_index.xml permanent; | |
## this makes the XML sitemaps work | |
rewrite ^/([a-z]+)?-?sitemap\.xsl$ /index.php?xsl=$1 last; | |
rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last; | |
rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last; | |
} | |
## | |
# Wordpress super cache setup | |
## | |
set $cache_uri $request_uri; | |
# POST requests and urls with a query string should always go to PHP | |
if ($request_method = POST) { | |
set $cache_uri 'null cache'; | |
} | |
if ($query_string != "") { | |
set $cache_uri 'null cache'; | |
} | |
# Don't cache uris containing the following segments | |
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { | |
set $cache_uri 'null cache'; | |
} | |
# Don't use the cache for logged in users or recent commenters | |
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") { | |
set $cache_uri 'null cache'; | |
} | |
# Use cached or actual file if they exists, otherwise pass request to WordPress | |
location / { | |
try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php ; | |
} | |
# Some security settings | |
location = /favicon.ico { log_not_found off; access_log off; } | |
location = /robots.txt { log_not_found off; access_log off; } | |
location ~ /\. { deny all; log_not_found off; access_log off; } | |
location ~ \.(hh|php)$ { | |
proxy_intercept_errors on; | |
proxy_buffer_size 128k; | |
proxy_buffers 4 128k; | |
fastcgi_keep_conn on; | |
fastcgi_buffer_size 128k; | |
fastcgi_buffers 256 16k; | |
fastcgi_busy_buffers_size 256k; | |
fastcgi_temp_file_write_size 256k; | |
fastcgi_pass unix:/var/run/hhvm/hhvm.sock; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_split_path_info ^(.+\.php)(.*)$; | |
include fastcgi_params; | |
} | |
# Nginx CDN access control | |
location ~* \.(eot|ttf|otf|woff)$ { | |
add_header Access-Control-Allow-Origin *; | |
} | |
# Set image format types to expire in a very long time | |
location ~* \.(?:ico|css|js|gif|jpe?g|png|svg|html|xml|otf|ttf|eot|woff)$ { | |
expires 14d; | |
access_log off; | |
add_header Pragma public; | |
add_header Cache-Control "public"; | |
} | |
# Cache static files for as long as possible | |
location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { | |
expires 30d; | |
log_not_found off; | |
access_log off; | |
add_header Cache-Control public; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment