server { listen 80 default_server; set $host_path "/alidata/www/public"; access_log /alidata/server/nginx/logs/www.access.log; error_log /alidata/server/nginx/logs/www.error.log; server_name ZHIPUZI_WWW_URL; root $host_path; set $yii_bootstrap "index.php"; charset utf-8; if ($query_string ~ "\?") { return 404; } location / { allow 113.87.15.0/24; allow 100.116.252.0/24; deny all; index index.html $yii_bootstrap; try_files $uri $uri/ /$yii_bootstrap?$args; } location ~ ^/(protected|framework|themes/\w+/views) { deny all; } #avoid processing of calls to unexisting static files by yii location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar|mp3|wav)$ { #expires 30d; #try_files $uri =404; rewrite ^(.*) https://ZHIPUZI_ASSETS_URL$1 permanent; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php { fastcgi_split_path_info ^(.+\.php)(.*)$; #let yii catch the calls to unexising PHP files set $fsn /$yii_bootstrap; if (-f $document_root$fastcgi_script_name){ set $fsn $fastcgi_script_name; } fastcgi_pass localhost:9000; fastcgi_index index.php; include fastcgi.conf; fastcgi_param SCRIPT_FILENAME $document_root$fsn; #PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fsn; } # prevent nginx from serving dotfiles (.htaccess, .svn, .git, etc.) location ~ /\. { deny all; access_log off; log_not_found off; } }