Last active
June 10, 2016 23:10
-
-
Save tommymarshall/46f976f186398f95e8e0 to your computer and use it in GitHub Desktop.
Craft nginx 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
server { | |
listen 80; | |
# route www to non-www | |
server_name www.clientsite.com; | |
return 301 $scheme://clientsite.com$request_uri; | |
} | |
server { | |
listen 80 default_server; | |
server_name clientsite.com; | |
root /home/forge/default/public; | |
# FORGE SSL (DO NOT REMOVE!) | |
# ssl on; | |
# ssl_certificate; | |
# ssl_certificate_key; | |
index index.html index.htm index.php; | |
charset utf-8; | |
location / { | |
try_files $uri $uri/ /index.php?$query_string&$args; | |
} | |
location = /favicon.ico { access_log off; log_not_found off; } | |
location = /robots.txt { access_log off; log_not_found off; } | |
access_log off; | |
error_log /var/log/nginx/default-error.log error; | |
error_page 404 /index.php; | |
# gzip compression | |
gzip on; | |
gzip_http_version 1.1; | |
gzip_vary on; | |
gzip_comp_level 6; | |
gzip_proxied any; | |
gzip_types text/plain text/html text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml; | |
# Cross domain webfont access | |
location ~* \.(?:ttf|ttc|otf|eot|woff|woff2)$ { | |
try_files $uri $uri/ /index.php?$query_string&$args; | |
add_header "Access-Control-Allow-Origin" "*"; | |
expires 1M; | |
} | |
# Cache images | |
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ { | |
try_files $uri $uri/ /index.php?$query_string&$args; | |
expires 1M; | |
} | |
# Cache css and js | |
location ~* \.(?:css|js)$ { | |
try_files $uri $uri/ /index.php?$query_string&$args; | |
expires 1y; | |
} | |
location ~ \.php$ { | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment