Nginx负载均衡配置的菜鸟修炼秘籍

Nginx负载均衡配置是一个十分重要的命令,要如何才能掌握好呢?下面我们就来仔细的学习下有关于Nginx负载均衡配置的相关命令编写。希望大家在之后的使用中有所收获。

 
 
 
  1. user nobody; #work user  
  2. worker_processes 1; #work process number, acording to you cpu number  
  3. #error_log logs/error.log;  
  4. #error_log logs/error.log notice;  
  5. #error_log logs/error.log info;  
  6. #pid logs/Nginx.pid;  
  7. events {  
  8. use epoll; #linux best event mode  
  9. worker_connections 1024; # most connects of one work process  
  10. }  
  11. http {  
  12. include mime.types;  
  13. default_type application/octet-stream;  
  14. log_format main '$remote_addr - $remote_user [$time_local] $request '  
  15. '"$status" $body_bytes_sent "$http_referer" '  
  16. '"$http_user_agent" "$http_x_forwarded_for"';  
  17. access_log logs/access.log main; # log file name  
  18. sendfile on;  
  19. #tcp_nopush on;  
  20. #keepalive_timeout 0;  
  21. keepalive_timeout 65;  
  22. #gzip on;  
  23. upstream itsm {  
  24. ip_hash;  
  25. server localhost:8081;  
  26. server localhost:8082;  
  27. }  
  28. server {  
  29. listen 80;  
  30. server_name www.kiko.com;  
  31. charset utf-8;  
  32. access_log logs/host.access.log main;  
  33. location /Nginxstatus {  
  34. stub_status on; #Nginx status watch  
  35. access_log off;  
  36. }  
  37. location / {  
  38. proxy_pass http://itsm;  
  39. proxy_set_header X-Real-IP $remote_addr;  
  40. }  
  41. #location / {  
  42. # root html;  
  43. # index index.html index.htm;  
  44. #}  
  45. #error_page 404 /404.html;  
  46. # redirect server error pages to the static page /50x.html  
  47. #  
  48. error_page 500 502 503 504 /50x.html;  
  49. location = /50x.html {  
  50. root html;  
  51. }  
  52. }  

 

以上就是对Nginx负载均衡配置的详细介绍。希望大家有所收获。

【编辑推荐】

  1. Nginx重启的简单命令 kill
  2. 深入学习有关Nginx负载均衡的安装过程
  3. 修改Nginx php.ini文件的经典教程
  4. Nginx反向代理支持的各种编程语言
  5. Nginx内核优化的源代码探秘
THE END