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

开发 前端
Nginx负载均衡配置对于很多网管员来说都是一项十分重要的必修课。下面的文章主要介绍了有关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内核优化的源代码探秘
责任编辑:张浩 来源: IT168
相关推荐

2014-07-28 11:37:49

NginxTomcat

2010-03-25 18:52:15

Nginx负载均衡

2010-05-04 13:32:37

nginx负载均衡器

2013-04-22 11:29:14

Nginx

2012-07-31 09:25:42

nginx负载均衡反向代理

2012-12-07 10:14:48

Nginx负载均衡

2010-05-07 12:23:23

nginx负载均衡

2010-05-04 13:38:25

nginx负载均衡器

2011-12-02 22:51:46

Nginx负载均衡

2019-07-09 15:10:02

Nginx反向代理负载均衡

2017-12-18 12:04:02

Nginx代理均衡

2010-05-07 12:27:53

nginx负载均衡

2011-02-17 09:45:54

FreeBSD 8.1nginx负载均衡

2021-04-15 11:22:36

运维架构技术

2011-01-07 11:14:17

Nginx负载均衡负载均衡

2010-05-06 10:01:26

nginx负载均衡

2011-09-01 10:23:47

Nginx负载均衡器负载均衡

2010-04-25 17:05:48

lvs负载均衡

2020-04-20 20:27:59

Nginx动静分离负载均衡

2018-02-01 10:31:12

Nginx负载均衡软件
点赞
收藏

51CTO技术栈公众号