Advertisement
Pothi

nginx-nested-locations

May 17th, 2013
590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. server {
  2. server_name www.sitename.com;
  3. rewrite ^(.*) http://sitename.com$1 permanent;
  4. }
  5.  
  6. server {
  7. listen 80;
  8. server_name sitename.com;
  9. root /var/www/sitename.com/htdocs/blog;
  10. index index.php;
  11. include /etc/nginx/security;
  12.  
  13. # Logging --
  14. access_log off;
  15. error_log /var/log/nginx/sitename.com.error.log warn;
  16.  
  17. location = /favicon.ico {
  18. log_not_found off;
  19. access_log off;
  20. }
  21.  
  22. location = /robots.txt {
  23. allow all;
  24. log_not_found off;
  25. access_log off;
  26. }
  27.  
  28. # serve static files directly
  29. location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ {
  30. access_log off;
  31. expires max;
  32. }
  33.  
  34. location /api {
  35. try_files $uri $uri/ /index.php?$args;
  36. root /var/www/sitename.com/htdocs;
  37. index index.php;
  38.  
  39. location ~ \.php$ {
  40. try_files $uri $uri/ /index.php?$args;
  41. fastcgi_pass unix:/var/run/php5-fpm/sitename.com.socket;
  42. fastcgi_index index.php;
  43. include /etc/nginx/fastcgi_params;
  44. }
  45.  
  46. }
  47.  
  48. location ~ \.php$ {
  49. try_files $uri $uri/ /index.php?$args;
  50. fastcgi_pass unix:/var/run/php5-fpm/sitename.com.socket;
  51. fastcgi_index index.php;
  52. include /etc/nginx/fastcgi_params;
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement