nginx.conf 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. user nginx nginx;
  2. daemon off;
  3. worker_processes 4;
  4. pid /var/run/nginx.pid;
  5. events {
  6. worker_connections 768;
  7. }
  8. http {
  9. include mime.types;
  10. default_type application/octet-stream;
  11. keepalive_timeout 20;
  12. client_max_body_size 10m;
  13. index index.html index.php;
  14. server {
  15. listen 80;
  16. root /var/www/shaarli;
  17. access_log /var/log/nginx/shaarli.access.log;
  18. error_log /var/log/nginx/shaarli.error.log;
  19. location ~ /\. {
  20. # deny access to dotfiles
  21. access_log off;
  22. log_not_found off;
  23. deny all;
  24. }
  25. location ~ ~$ {
  26. # deny access to temp editor files, e.g. "script.php~"
  27. access_log off;
  28. log_not_found off;
  29. deny all;
  30. }
  31. location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
  32. # cache static assets
  33. expires max;
  34. add_header Pragma public;
  35. add_header Cache-Control "public, must-revalidate, proxy-revalidate";
  36. }
  37. location = /favicon.ico {
  38. # serve the Shaarli favicon from its custom location
  39. alias /var/www/shaarli/images/favicon.ico;
  40. }
  41. location / {
  42. # Slim - rewrite URLs
  43. try_files $uri /index.php$is_args$args;
  44. }
  45. location ~ (index)\.php$ {
  46. # Slim - split URL path into (script_filename, path_info)
  47. try_files $uri =404;
  48. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  49. # filter and proxy PHP requests to PHP-FPM
  50. fastcgi_pass unix:/var/run/php-fpm.sock;
  51. fastcgi_index index.php;
  52. include fastcgi.conf;
  53. }
  54. location ~ \.php$ {
  55. # deny access to all other PHP scripts
  56. deny all;
  57. }
  58. }
  59. }