Last active
December 19, 2015 06:18
-
-
Save JesseObrien/5910044 to your computer and use it in GitHub Desktop.
A Good Nginx Config
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; | |
# Uncomment for SSL | |
#listen 443; | |
server_name example.com www.example.com; | |
# Uncomment for SSL | |
#ssl on; | |
#ssl_certificate /etc/ssl/mycert.crt; | |
#ssl_certificate_key /etc/ssl/mycert.key; | |
access_log /var/log/nginx/mysite.access.log; | |
root /myproject/public; | |
index index.php index.htm index.html; | |
gzip on; | |
gzip_static on; | |
gzip_http_version 1.0; | |
gzip_disable "MSIE [1-6]."; | |
gzip_vary on; | |
gzip_comp_level 9; | |
gzip_proxied any; | |
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript; | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
# Example rewrite condition | |
# rewrite ^/blog/2013/01/01/(.*)$ http://example.com/posts/$1 last; | |
} | |
location ~* \.php$ { | |
root /myproject/public; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
fastcgi_split_path_info ^(.+\.php)(.*)$; | |
include /etc/nginx/fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
} | |
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ { | |
expires max; | |
add_header Pragma public; | |
add_header Cache-Control "public, must-revalidate, proxy-revalidate"; | |
} | |
location ~ /\.ht { | |
deny all; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment