nginx.conf 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. worker_processes 1;
  2. error_log stderr warn;
  3. pid /run/nginx.pid;
  4. events {
  5. worker_connections 1024;
  6. }
  7. http {
  8. include mime.types;
  9. default_type application/octet-stream;
  10. # Define custom log format to include reponse times
  11. log_format main_timed '$remote_addr - $remote_user [$time_local] "$request" '
  12. '$status $body_bytes_sent "$http_referer" '
  13. '"$http_user_agent" "$http_x_forwarded_for" '
  14. '$request_time $upstream_response_time $pipe $upstream_cache_status';
  15. access_log /dev/stdout main_timed;
  16. error_log /dev/stderr notice;
  17. keepalive_timeout 65;
  18. # Write temporary files to /tmp so they can be created as a non-privileged user
  19. client_body_temp_path /tmp/client_temp;
  20. proxy_temp_path /tmp/proxy_temp_path;
  21. fastcgi_temp_path /tmp/fastcgi_temp;
  22. uwsgi_temp_path /tmp/uwsgi_temp;
  23. scgi_temp_path /tmp/scgi_temp;
  24. # Default server definition
  25. server {
  26. listen 8080 default_server;
  27. server_name _;
  28. sendfile off;
  29. # Increase proxy buffers for large requests
  30. proxy_buffer_size 128k;
  31. proxy_buffers 4 256k;
  32. proxy_busy_buffers_size 256k;
  33. # Upload limit
  34. client_max_body_size ${client_max_body_size};
  35. client_body_buffer_size 128k;
  36. root /var/www/html/public;
  37. index index.php index.html;
  38. location / {
  39. # First attempt to serve request as file, then
  40. # as directory, then fall back to index.php
  41. try_files $uri $uri/ /index.php?q=$uri&$args;
  42. }
  43. # Redirect server error pages to the static page /50x.html
  44. error_page 500 502 503 504 /50x.html;
  45. location = /50x.html {
  46. root /var/lib/nginx/html;
  47. }
  48. # Pass the PHP scripts to PHP-FPM listening on 127.0.0.1:9000
  49. location ~ [^/]\.php(/|$) {
  50. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  51. fastcgi_pass 127.0.0.1:9000;
  52. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  53. fastcgi_param SCRIPT_NAME $fastcgi_script_name;
  54. fastcgi_param PATH_INFO $fastcgi_path_info;
  55. fastcgi_index index.php;
  56. include fastcgi_params;
  57. }
  58. location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
  59. expires 5d;
  60. }
  61. # Deny access to . files, for security
  62. location ~ /\. {
  63. log_not_found off;
  64. deny all;
  65. }
  66. # Allow fpm ping and status from localhost
  67. location ~ ^/(fpm-status|fpm-ping)$ {
  68. access_log off;
  69. allow 127.0.0.1;
  70. deny all;
  71. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  72. include fastcgi_params;
  73. fastcgi_pass 127.0.0.1:9000;
  74. }
  75. }
  76. # Include other server configs
  77. include /etc/nginx/conf.d/*.conf;
  78. gzip on;
  79. gzip_proxied any;
  80. gzip_types text/plain application/xml text/css text/js text/xml application/x-javascript text/javascript application/json application/xml+rss;
  81. gzip_vary on;
  82. gzip_disable "msie6";
  83. }