使用nginx的tcp負載解決exchange2016的客戶端訪問負載
安裝nginx過程就參考nginx官網咖,
這裡提供一下具體我的測試環境中nginx的配置
修改配置檔案:
vim /etc/nginx/nginx.conf
具體內容如下:
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
}
#負載exchange2016前端的模組配置
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
}
#負載exchange2016前端的模組配置
stream {
upstream mail {
least_conn;//連線數進行負載
server 172.20.224.136:443 max_fails=2 fail_timeout=10s;//被動檢查伺服器響應
server 172.20.224.57:443 max_fails=2 fail_timeout=10s;
}
upstream mail {
least_conn;//連線數進行負載
server 172.20.224.136:443 max_fails=2 fail_timeout=10s;//被動檢查伺服器響應
server 172.20.224.57:443 max_fails=2 fail_timeout=10s;
}
server {
listen 443;
proxy_pass mail;
proxy_timeout 3s;
proxy_connect_timeout 1s;
}
listen 443;
proxy_pass mail;
proxy_timeout 3s;
proxy_connect_timeout 1s;
}
upstream smtp {
least_conn;
server 172.20.224.136:25 max_fails=2 fail_timeout=10s;
server 172.20.224.57:25 max_fails=2 fail_timeout=10s;
}
least_conn;
server 172.20.224.136:25 max_fails=2 fail_timeout=10s;
server 172.20.224.57:25 max_fails=2 fail_timeout=10s;
}
server {
listen 25;
proxy_pass smtp;
proxy_timeout 3s;
proxy_connect_timeout 1s;
}
listen 25;
proxy_pass smtp;
proxy_timeout 3s;
proxy_connect_timeout 1s;
}
upstream pop {
least_conn;
server 172.20.224.136:110 max_fails=2 fail_timeout=10s;
server 172.20.224.57:110 max_fails=2 fail_timeout=10s;
}
least_conn;
server 172.20.224.136:110 max_fails=2 fail_timeout=10s;
server 172.20.224.57:110 max_fails=2 fail_timeout=10s;
}
server {
listen 110;
proxy_pass pop;
proxy_timeout 3s;
proxy_connect_timeout 1s;
}
listen 110;
proxy_pass pop;
proxy_timeout 3s;
proxy_connect_timeout 1s;
}
upstream imap {
least_conn;
server 172.20.224.136:143 max_fails=2 fail_timeout=10s;
server 172.20.224.57:143 max_fails=2 fail_timeout=10s;
}
least_conn;
server 172.20.224.136:143 max_fails=2 fail_timeout=10s;
server 172.20.224.57:143 max_fails=2 fail_timeout=10s;
}
server {
listen 143;
proxy_pass imap;
proxy_timeout 3s;
proxy_connect_timeout 1s;
}
listen 143;
proxy_pass imap;
proxy_timeout 3s;
proxy_connect_timeout 1s;
}
upstream pops {
least_conn;
server 172.20.224.136:995 max_fails=2 fail_timeout=10s;
server 172.20.224.57:995 max_fails=2 fail_timeout=10s;
}
least_conn;
server 172.20.224.136:995 max_fails=2 fail_timeout=10s;
server 172.20.224.57:995 max_fails=2 fail_timeout=10s;
}
server {
listen 995;
proxy_pass pops;
proxy_timeout 3s;
proxy_connect_timeout 1s;
}
upstream imaps {
least_conn;
server 172.20.224.136:993 max_fails=2 fail_timeout=10s;
server 172.20.224.57:993 max_fails=2 fail_timeout=10s;
}
listen 995;
proxy_pass pops;
proxy_timeout 3s;
proxy_connect_timeout 1s;
}
upstream imaps {
least_conn;
server 172.20.224.136:993 max_fails=2 fail_timeout=10s;
server 172.20.224.57:993 max_fails=2 fail_timeout=10s;
}
server {
listen 993;
proxy_pass imaps;
proxy_timeout 3s;
proxy_connect_timeout 1s;
}
listen 993;
proxy_pass imaps;
proxy_timeout 3s;
proxy_connect_timeout 1s;
}
upstream smtps {
least_conn;
server 172.20.224.136:587 max_fails=2 fail_timeout=10s;
server 172.20.224.57:587 max_fails=2 fail_timeout=10s;
}
least_conn;
server 172.20.224.136:587 max_fails=2 fail_timeout=10s;
server 172.20.224.57:587 max_fails=2 fail_timeout=10s;
}
server {
listen 587;
proxy_pass smtps;
proxy_timeout 3s;
proxy_connect_timeout 1s;
}
listen 587;
proxy_pass smtps;
proxy_timeout 3s;
proxy_connect_timeout 1s;
}
upstream smtps1 {
least_conn;
server 172.20.224.136:465 max_fails=2 fail_timeout=10s;
server 172.20.224.57:465 max_fails=2 fail_timeout=10s;
}
least_conn;
server 172.20.224.136:465 max_fails=2 fail_timeout=10s;
server 172.20.224.57:465 max_fails=2 fail_timeout=10s;
}
server {
listen 465;
proxy_pass smtps1;
proxy_timeout 3s;
proxy_connect_timeout 1s;
}
listen 465;
proxy_pass smtps1;
proxy_timeout 3s;
proxy_connect_timeout 1s;
}
}
配置使用wq推出儲存,在使用命令
cd /etc/nginx/nginx.d
nginx -s reload
重新載入服務之後就可以使用了
相關文章
- gRPC負載均衡(客戶端負載均衡)RPC負載客戶端
- 使用Nginx配置TCP負載均衡NginxTCP負載
- 客戶端負載均衡配置客戶端負載
- mysqlslap 負載模擬客戶端MySql負載客戶端
- Nginx 的 TCP 負載均衡介紹NginxTCP負載
- Oracle RAC 客戶端負載均衡配置Oracle客戶端負載
- SpringCloud客戶端負載均衡——RibbonSpringGCCloud客戶端負載
- SpringCloud 客戶端負載均衡:RibbonSpringGCCloud客戶端負載
- ③SpringCloud 實戰:使用 Ribbon 客戶端負載均衡SpringGCCloud客戶端負載
- 使用tengine解決負載均衡的session問題負載Session
- Spring Cloud Ribbon 客戶端負載均衡SpringCloud客戶端負載
- Nginx負載均衡詳解Nginx負載
- RocketMQ 客戶端負載均衡機制詳解及最佳實踐MQ客戶端負載
- NGINX 負載均衡Nginx負載
- nginx負載均衡Nginx負載
- Nginx負載配置Nginx負載
- 【Nginx】負載均衡Nginx負載
- (23)go-micro微服務客戶端開發(使用負載均衡)Go微服務客戶端負載
- Tengine TCP 負載均衡TCP負載
- spring cloud 上雲的情況下,Ribbon 客戶端負載均衡 與 ALB 服務端負載均衡的選擇SpringCloud客戶端負載服務端
- nginx 負載均衡 使用ip_hash方式解決session問題 測試Nginx負載Session
- 使用nginx進行負載均衡Nginx負載
- 使用nginx負載均衡nodejsNginx負載NodeJS
- Spring RestTemplate作為負載平衡器客戶端SpringREST負載客戶端
- 微服務架構如何實現客戶端負載均衡微服務架構客戶端負載
- 【SpringCloud】(六):Ribbon實現客戶端負載均衡SpringGCCloud客戶端負載
- 使用 haproxy 進行 TCP 負載均衡TCP負載
- Nginx中的負載平衡方法Nginx負載
- Spring cloud客戶端負載均衡與ribbon的設計思路SpringCloud客戶端負載
- Nginx負載均衡模式Nginx負載模式
- Nginx--負載均衡Nginx負載
- nginx 負載均衡搭建Nginx負載
- Nginx負載均衡策略Nginx負載
- 解析 Nginx 負載均衡Nginx負載
- nginx詳解反向代理負載均衡Nginx負載
- openGauss JDBC客戶端負載均衡與讀寫分離JDBC客戶端負載
- Nginx/ZooKeeper 負載均衡的差異Nginx負載
- SpringCloud系列之客戶端負載均衡Netflix RibbonSpringGCCloud客戶端負載