Skip to content

Instantly share code, notes, and snippets.

@nineinchnick
Created May 23, 2015 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nineinchnick/414b91a88b6560c5d8ba to your computer and use it in GitHub Desktop.
Save nineinchnick/414b91a88b6560c5d8ba to your computer and use it in GitHub Desktop.
nginx vhost
server {
listen 80;
server_name site.local;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name site.local;
ssl on;
ssl_certificate /etc/ssl/certs/snakeoil.pem;
ssl_certificate_key /etc/ssl/private/snakeoil.key;
access_log /var/log/nginx/site-access.log;
error_log /var/log/nginx/site-error.log;
root /srv/http/site/web;
if ($ssl_protocol = "") {
rewrite ^ https://$server_name$request_uri? permanent;
}
location / {
try_files $uri @php_index;
}
location ~ /\. {
deny all;
}
location ~* ^/assets/ {
# don't log requests
access_log off;
# Per RFC2616 - 1 year maximum expiry
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
expires 1y;
add_header Cache-Control public;
# Some browsers still send conditional-GET requests if there's a
# Last-Modified header or an ETag header even if they haven't
# reached the expiry date sent in the Expires header.
add_header Last-Modified "";
add_header ETag "";
break;
}
location @php_index {
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
#fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_param YII_DEBUG true;
fastcgi_param YII_ENV dev;
#fastcgi_read_timeout 3600;
include fastcgi_params;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment