• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
孙龙 程序员
少时总觉为人易,华年方知立业难
博客园    首页    新随笔    联系   管理    订阅  订阅
nginx负载均衡

  1 #user  nobody;
  2 worker_processes  1;
  3 
  4 #error_log  logs/error.log;
  5 #error_log  logs/error.log  notice;
  6 #error_log  logs/error.log  info;
  7 
  8 #pid        logs/nginx.pid;
  9 
 10 
 11 events {
 12     worker_connections  1024;
 13 }
 14 
 15 
 16 http {
 17     include       mime.types;
 18     default_type  application/octet-stream;
 19 
 20     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
 21                       '$status $body_bytes_sent "$http_referer" '
 22                       '"$http_user_agent" "$http_x_forwarded_for"';
 23 
 24     access_log  logs/access.log  main;
 25 
 26     sendfile        on;
 27     #tcp_nopush     on;
 28 
 29     #keepalive_timeout  0;
 30     keepalive_timeout  65;
 31 
 32     #gzip  on;
 33     upstream mytomcat{
 34     ip_hash;
 35     server  192.168.100.66:9190 weight=1;
 36     server  192.168.100.67:9190 weight=1;
 37    }
 38 
 39     server {
 40        # listen       80;
 41         listen       443 ssl;
 42         server_name  localhost;
 43 
 44     ssl_certificate     /mnt/yuanqi/zs/xq/cert-1541604042700_xqyy.1451cn.com.crt;
 45     ssl_certificate_key /mnt/yuanqi/zs/xq/cert-1541604042700_xqyy.1451cn.com.key;
 46 
 47     ssl_session_cache    shared:SSL:1m;
 48     ssl_session_timeout  5m;
 49     #ssl_protocols        TLSv1;
 50     #ssl_ciphers          HIGH:aNULL:!MD5;
 51     #ssl_prefer_server_ciphers  on;
 52     ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #按照这个协议配置 这里不需要更改
 53         ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#按照这个套件配置 这里不需要更改
 54         ssl_prefer_server_ciphers on;
 55 
 56         #charset koi8-r;
 57 
 58         #access_log  logs/host.access.log  main;
 59     proxy_redirect http:// $scheme://;
 60     port_in_redirect on;
 61 
 62         location / {
 63             proxy_pass http://mytomcat;
 64         proxy_set_header Host $host:$server_port;
 65                  proxy_set_header X-Real-IP $remote_addr;
 66                  proxy_set_header REMOTE-HOST $remote_addr;
 67                  proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
 68                  proxy_set_header X-Forwarded-Ssl on;
 69         proxy_set_header X-Forwarded-Proto  $scheme;
 70     }
 71 
 72 }
 73     # another virtual host using mix of IP-, name-, and port-based configuration
 74     #
 75     #server {
 76     #    listen       8000;
 77     #    listen       somename:8080;
 78     #    server_name  somename  alias  another.alias;
 79 
 80     #    location / {
 81     #        root   html;
 82     #        index  index.html index.htm;
 83     #    }
 84     #}
 85 
 86 
 87     # HTTPS server
 88     #
 89     #server {
 90     #    listen       443 ssl;
 91     #    server_name  localhost;
 92 
 93     #    ssl_certificate      cert.pem;
 94     #    ssl_certificate_key  cert.key;
 95 
 96     #    ssl_session_cache    shared:SSL:1m;
 97     #    ssl_session_timeout  5m;
 98 
 99     #    ssl_ciphers  HIGH:!aNULL:!MD5;
100     #    ssl_prefer_server_ciphers  on;
101 
102     #    location / {
103     #        root   html;
104     #        index  index.html index.htm;
105     #    }
106     #}
107 
108 }
65

 

 1 #user  nobody;
 2 worker_processes  1;
 3 
 4 #error_log  logs/error.log;
 5 #error_log  logs/error.log  notice;
 6 #error_log  logs/error.log  info;
 7 
 8 #pid        logs/nginx.pid;
 9 
10 
11 events {
12     worker_connections  1024;
13 }
14 
15 
16 http {
17     include       mime.types;
18     default_type  application/octet-stream;
19 
20     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
21                       '$status $body_bytes_sent "$http_referer" '
22                       '"$http_user_agent" "$http_x_forwarded_for"';
23 
24     access_log  logs/access.log  main;
25 
26     sendfile        on;
27     #tcp_nopush     on;
28 
29     #keepalive_timeout  0;
30     keepalive_timeout  65;
31 
32     upstream sxl_9192{
33     ip_hash;
34     server 192.168.100.99:9192;
35     server 192.168.100.99:9194;
36     }
37 
38     upstream sxl_9193{
39     ip_hash;
40     server 192.168.100.99:9193;
41     server 192.168.100.99:9195;
42     }
43 
44     #gzip  on;
45 
46     #
47     server {
48         listen       9192;
49     #    listen       somename:8080;
50         server_name  localhost;
51 
52         location / {
53     #        root   html;
54     #        index  index.html index.htm;
55             proxy_pass http://sxl_9192;
56             proxy_redirect off;
57             proxy_set_header Host $host;
58             proxy_set_header X-Real-IP $remote_addr;
59             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
60         }
61     }
62 
63     server {
64     listen    9193;
65     server_name localhost;
66     
67     location / {
68         proxy_pass http://sxl_9193;
69             proxy_redirect off;
70             proxy_set_header Host $host;
71             proxy_set_header X-Real-IP $remote_addr;
72             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
73 
74     }
75     }
76 
77 
78     # HTTPS server
79     #
80     #server {
81     #    listen       443 ssl;
82     #    server_name  localhost;
83 
84     #    ssl_certificate      cert.pem;
85     #    ssl_certificate_key  cert.key;
86 
87     #    ssl_session_cache    shared:SSL:1m;
88     #    ssl_session_timeout  5m;
89 
90     #    ssl_ciphers  HIGH:!aNULL:!MD5;
91     #    ssl_prefer_server_ciphers  on;
92 
93     #    location / {
94     #        root   html;
95     #        index  index.html index.htm;
96     #    }
97     #}
98     #include /application/nginx/conf.d/*.conf;
99 }
66

 

  1 #user  nobody;
  2 worker_processes  1;
  3 
  4 #error_log  logs/error.log;
  5 #error_log  logs/error.log  notice;
  6 #error_log  logs/error.log  info;
  7 
  8 #pid        logs/nginx.pid;
  9 
 10 
 11 events {
 12     worker_connections  1024;
 13 }
 14 
 15 
 16 http {
 17     include       mime.types;
 18     default_type  application/octet-stream;
 19 
 20     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
 21                       '$status $body_bytes_sent "$http_referer" '
 22                       '"$http_user_agent" "$http_x_forwarded_for"';
 23 
 24     access_log  logs/access.log  main;
 25 
 26     sendfile        on;
 27     #tcp_nopush     on;
 28 
 29     #keepalive_timeout  0;
 30     keepalive_timeout  65;
 31 
 32     #gzip  on;
 33 
 34    upstream sxl_9192{
 35         ip_hash;
 36         server 192.168.100.99:9192;
 37         server 192.168.100.99:9194;
 38     }
 39 
 40     upstream sxl_9193{
 41         ip_hash;
 42         server 192.168.100.99:9193;
 43         server 192.168.100.99:9195;
 44     }
 45 
 46 
 47     # another virtual host using mix of IP-, name-, and port-based configuration
 48     #
 49     server {
 50         listen       9192;
 51         server_name  localhost;
 52         #server_name  somename  alias  another.alias;
 53 
 54         location / {
 55             #root   html;
 56             #index  index.html index.htm;
 57             proxy_pass http://sxl_9192;
 58         proxy_redirect off;
 59         proxy_set_header Host $host;
 60          proxy_set_header X-Real-IP $remote_addr;
 61         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 62         }
 63     }
 64 
 65     server {
 66         listen       9193;
 67         server_name  localhost;
 68         #server_name  somename  alias  another.alias;
 69         
 70         location / {
 71         #root   html;
 72             #index  index.html index.htm;
 73             proxy_pass http://sxl_9193;
 74         proxy_redirect off;
 75         proxy_set_header Host $host;
 76         proxy_set_header X-Real-IP $remote_addr;
 77          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 78          }
 79     }
 80 
 81     # HTTPS server
 82     #
 83     #server {
 84     #    listen       443 ssl;
 85     #    server_name  localhost;
 86 
 87     #    ssl_certificate      cert.pem;
 88     #    ssl_certificate_key  cert.key;
 89 
 90     #    ssl_session_cache    shared:SSL:1m;
 91     #    ssl_session_timeout  5m;
 92 
 93     #    ssl_ciphers  HIGH:!aNULL:!MD5;
 94     #    ssl_prefer_server_ciphers  on;
 95 
 96     #    location / {
 97     #        root   html;
 98     #        index  index.html index.htm;
 99     #    }
100     #}
101     #include /application/nginx/conf.d/*.conf;
102 }
67

 

本文来自博客园,作者:孙龙-程序员,转载请注明原文链接:https://www.cnblogs.com/sunlong88/articles/9984568.html

posted on 2018-11-19 18:18  孙龙-程序员  阅读(117)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3