A complete configuration example nginx.conf (used in a production environment)

Source: Internet
Author: User

A complete nginx configuration case, production environment


   
  
  1. A complete configuration example (used in a production environment)
  2. User nobody nobody;
  3. Worker_processes 4;
  4. Worker_rlimit_nofile 51200;
  5. Error_log Logs/error.log Notice;
  6. Pid/var/run/nginx.pid;
  7. Events {
  8. Use Epoll;
  9. Worker_connections 51200;
  10. }
  11. HTTP {
  12. Server_tokens off;
  13. Include Mime.types;
  14. Proxy_redirect off;
  15. Proxy_set_header Host $host;
  16. Proxy_set_header X-real-ip $remote _addr;
  17. Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
  18. Client_max_body_size 20m;
  19. Client_body_buffer_size 256k;
  20. Proxy_connect_timeout 90;
  21. Proxy_send_timeout 90;
  22. Proxy_read_timeout 90;
  23. Proxy_buffer_size 128k;
  24. Proxy_buffers 4 64k;
  25. Proxy_busy_buffers_size 128k;
  26. Proxy_temp_file_write_size 128k;
  27. Default_type Application/octet-stream;
  28. CharSet Utf-8;
  29. Client_body_temp_path/var/tmp/client_body_temp 1 2;
  30. Proxy_temp_path/var/tmp/proxy_temp 1 2;
  31. Fastcgi_temp_path/var/tmp/fastcgi_temp 1 2;
  32. Uwsgi_temp_path/var/tmp/uwsgi_temp 1 2;
  33. Scgi_temp_path/var/tmp/scgi_temp 1 2;
  34. Ignore_invalid_headers on;
  35. Server_names_hash_max_size 256;
  36. Server_names_hash_bucket_size 64;
  37. Client_header_buffer_size 8k;
  38. Large_client_header_buffers 4 32k;
  39. Connection_pool_size 256;
  40. Request_pool_size 64k;
  41. Output_buffers 2 128k;
  42. Postpone_output 1460;
  43. Client_header_timeout 1m;
  44. Client_body_timeout 3m;
  45. Send_timeout 3m;
  46. Log_format Main ' $server _addr $remote _addr [$time _local] $msec + $connection '
  47. ' $request ' $status $connection $request _time $body _bytes_sent "$http _referer"
  48. ' "$http _user_agent" "$http _x_forwarded_for";
  49. Open_log_file_cache max=1000 inactive=20s Min_uses=1 valid=1m;
  50. Access_log Logs/access.log Main;
  51. Log_not_found on;
  52. Sendfile on;
  53. Tcp_nodelay on;
  54. Tcp_nopush off;
  55. Reset_timedout_connection on;
  56. Keepalive_timeout 10 5;
  57. Keepalive_requests 100;
  58. gzip on;
  59. Gzip_http_version 1.1;
  60. Gzip_vary on;
  61. Gzip_proxied any;
  62. Gzip_min_length 1024;
  63. Gzip_comp_level 6;
  64. Gzip_buffers 8k;
  65. Gzip_proxied expired No-cache no-store private auth no_last_modified No_etag;
  66. Gzip_types text/plain application/x-javascript text/css application/xml Application/json;
  67. Gzip_disable "MSIE [1-6]\. (?!. *SV1) ";
  68. Upstream tomcat8080 {
  69. Ip_hash;
  70. Server 172.16.100.103:8080 weight=1 max_fails=2;
  71. Server 172.16.100.104:8080 weight=1 max_fails=2;
  72. Server 172.16.100.105:8080 weight=1 max_fails=2;
  73. }
  74. server {
  75. Listen 80;
  76. server_name www.magedu.com;
  77. # Config_apps_begin
  78. Root/data/webapps/htdocs;
  79. Access_log/var/logs/webapp.access.log main;
  80. Error_log/var/logs/webapp.error.log notice;
  81. Location/{
  82. Location ~* ^.*/favicon.ico$ {
  83. Root/data/webapps;
  84. Expires 180d;
  85. Break
  86. }
  87. if (!-f $request _filename) {
  88. Proxy_pass http://tomcat8080;
  89. Break
  90. }
  91. }
  92. Error_page 502 503 504/50x.html;
  93. Location =/50x.html {
  94. root HTML;
  95. }
  96. }
  97. server {
  98. Listen 8088;
  99. server_name nginx_status;
  100. Location/{
  101. Access_log off;
  102. Deny all;
  103. return 503;
  104. }
  105. Location/status {
  106. Stub_status on;
  107. Access_log off;
  108. Allow 127.0.0.1;
  109. Allow 172.16.100.71;
  110. Deny all;
  111. }
  112. }
  113. }

A complete configuration example nginx.conf (used in a production environment)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.