official.conf 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. server {
  2. listen 80 default_server;
  3. set $host_path "/alidata/www/public";
  4. access_log /alidata/server/nginx/logs/www.access.log;
  5. error_log /alidata/server/nginx/logs/www.error.log;
  6. server_name ZHIPUZI_WWW_URL;
  7. root $host_path;
  8. set $yii_bootstrap "index.php";
  9. charset utf-8;
  10. if ($query_string ~ "\?") {
  11. return 404;
  12. }
  13. location / {
  14. allow 113.87.15.0/24;
  15. allow 100.116.252.0/24;
  16. deny all;
  17. index index.html $yii_bootstrap;
  18. try_files $uri $uri/ /$yii_bootstrap?$args;
  19. }
  20. location ~ ^/(protected|framework|themes/\w+/views) {
  21. deny all;
  22. }
  23. #avoid processing of calls to unexisting static files by yii
  24. location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar|mp3|wav)$ {
  25. #expires 30d;
  26. #try_files $uri =404;
  27. rewrite ^(.*) https://ZHIPUZI_ASSETS_URL$1 permanent;
  28. }
  29. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  30. #
  31. location ~ \.php {
  32. fastcgi_split_path_info ^(.+\.php)(.*)$;
  33. #let yii catch the calls to unexising PHP files
  34. set $fsn /$yii_bootstrap;
  35. if (-f $document_root$fastcgi_script_name){
  36. set $fsn $fastcgi_script_name;
  37. }
  38. fastcgi_pass localhost:9000;
  39. fastcgi_index index.php;
  40. include fastcgi.conf;
  41. fastcgi_param SCRIPT_FILENAME $document_root$fsn;
  42. #PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI
  43. fastcgi_param PATH_INFO $fastcgi_path_info;
  44. fastcgi_param PATH_TRANSLATED $document_root$fsn;
  45. }
  46. # prevent nginx from serving dotfiles (.htaccess, .svn, .git, etc.)
  47. location ~ /\. {
  48. deny all;
  49. access_log off;
  50. log_not_found off;
  51. }
  52. }