nginx tomcat負載均衡

2021-07-13 20:48:47 字數 1235 閱讀 9753

nginx版本為1.9.15

必須關閉selinux,否則做請求**時會失敗報錯

關閉selinux

執行 setenforce 0

這個之後暫時關閉selinux,重啟後selinux還是開啟的,要永遠關閉selinux需修改配置檔案

vi /etc/selinux/config

將selinux設定為disabled

修改nginx配置檔案

新建/etc/nginx/conf.d/upstream.conf

內容如下

upstream localhost

修改/etc/nginx/conf.d/default.conf

server

#error_page  404              /404.html;

# redirect server error pages to the static page /50x.html

#error_page   500 502 503 504  /50x.html;

location = /50x.html

# proxy the php scripts to apache listening on 127.0.0.1:80

##location ~ \.php$

# pass the php scripts to fastcgi server listening on 127.0.0.1:9000

##location ~ \.php$

# deny access to .htaccess files, if apache's document root

# concurs with nginx's one

##location ~ /\.ht

}增加server_name  localhost;

location/下增加proxy_pass http://localhost;

重啟nginx

Nginx Tomcat負載均衡

使用nginx做 後台兩台tomcat伺服器做負載均衡,nginx和tomcat安裝在其他文章中都可以找到,這裡不做介紹。1 nginx配置 由於專案使用了websocket,所以需要nginx支援websocket,nginx從1.3版本開始支援websocket,所以對版本有一定要求,配置很簡單...

nginx tomcat負載均衡

安裝jdk 解壓,配置環境變數即可 2.安裝tomcat 安裝兩個tomcat,分別為tomcat1和tomcat2。接下來,修改tomcat埠。需修改三個埠 shutdown 埠 8005 主要負責啟動關閉.ajp埠 8009 主要負責通過ajp均衡 常用於apache和tomcat整合 http...

Nginx Tomcat負載均衡

需求 一台nginx伺服器,兩台tomcat伺服器,一台測試機 tomcat版本推薦使用8.5.16。1,建立tomcat 1 的web站點 root localhost mkdir p web html root localhost vim web html index.html www.tomc...