Advertisement
Guest User

Untitled

a guest
Aug 28th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. server {
  2. listen 80;
  3. server_name example.com;
  4.  
  5. access_log /var/log/nginx/example.com.access.log;
  6. error_log /var/log/nginx/example.com.error.log;
  7.  
  8. root /var/www/example.com;
  9. index index.php;
  10.  
  11. #browse folders if no index file
  12. autoindex on;
  13.  
  14. # serve static files directly
  15. location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
  16. access_log off;
  17. expires max;
  18. }
  19.  
  20. # removes trailing slashes (prevents SEO duplicate content issues)
  21. if (!-d $request_filename)
  22. {
  23. rewrite ^/(.+)/$ /$1 permanent;
  24. }
  25.  
  26. # removes trailing "index" from all controllers
  27. if ($request_uri ~* index/?$)
  28. {
  29. rewrite ^/(.*)/index/?$ /$1 permanent;
  30. }
  31.  
  32. # unless the request is for a valid file (image, js, css, etc.), send to bootstrap
  33. if (!-e $request_filename)
  34. {
  35. rewrite ^/(.*)$ /index.php?/$1 last;
  36. break;
  37. }
  38.  
  39. location ~ \.php$ {
  40. root /var/www/example.com;
  41. fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
  42. fastcgi_index index.php;
  43. fastcgi_param QUERY_STRING $query_string;
  44. fastcgi_param REQUEST_METHOD $request_method;
  45. fastcgi_param CONTENT_TYPE $content_type;
  46. fastcgi_param CONTENT_LENGTH $content_length;
  47.  
  48. fastcgi_param SCRIPT_NAME $fastcgi_script_name;
  49. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  50. fastcgi_param REQUEST_URI $request_uri;
  51. fastcgi_param DOCUMENT_URI $document_uri;
  52. fastcgi_param DOCUMENT_ROOT $document_root;
  53. fastcgi_param SERVER_PROTOCOL $server_protocol;
  54.  
  55. fastcgi_param GATEWAY_INTERFACE CGI/1.1;
  56. fastcgi_param SERVER_SOFTWARE nginx;
  57.  
  58. fastcgi_param REMOTE_ADDR $remote_addr;
  59. fastcgi_param REMOTE_PORT $remote_port;
  60. fastcgi_param SERVER_ADDR $server_addr;
  61. fastcgi_param SERVER_PORT $server_port;
  62. fastcgi_param SERVER_NAME $server_name;
  63. include fastcgi_params;
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement