下文給大家?guī)韓ginx反向代理工程加入負(fù)載均衡及動(dòng)靜分離配置詳解,希望能夠給大家在實(shí)際運(yùn)用中帶來一定的幫助,負(fù)載均衡涉及的東西比較多,理論也不多,網(wǎng)上有很多書籍,今天我們就用創(chuàng)新互聯(lián)在行業(yè)內(nèi)累計(jì)的經(jīng)驗(yàn)來做一個(gè)解答。

nginx反向代理多個(gè)工程,加入了負(fù)載均衡及動(dòng)靜分離的配置

#user nobody;
worker_processes 4;
error_log logs/error.log info;
pid logs/nginx.pid;
worker_rlimit_nofile 65535;
events {
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 300m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
server_tokens off;
client_body_buffer_size 512k;
proxy_connect_timeout 5;
proxy_send_timeout 60;
proxy_read_timeout 5;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
access_log logs/access.log main;
gzip on;
#負(fù)載均衡
upstream bsxm {
ip_hash;
server 192.168.1.193:8080;
}
#指定靜態(tài)頁(yè)面路徑
server {
listen 80;
server_name 192.168.1.193;
root C:\webapps\bsxmgw\pages;
index index.html index.htm;
#加載靜態(tài)文件 ,因?yàn)樵谙旅娴姆聪虼碇幸雅渲茫@里根據(jù)需求選用
#location ~ ^/(p_w_picpaths|javascript|js|css|flash|media|static)/ {
#root C:\webapps\bsxmgw;
#access_log off;
#expires 30d; #所有靜態(tài)文件緩存30天
# }
#反向代理配置
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#純反向代理配置
#location /webapps/
#{
#proxy_pass http://192.168.1.193:8080;
#}
#負(fù)載均衡
location ~ \.(jsp|action)$
{
proxy_pass http://bsxm;
# client_max_body_size 1000m;
}
location ~ \.(gif|jpg|jpeg|png|bmp|swf|flv)$
{
expires 30d;#所有靜態(tài)文件緩存30天
}
location ~ \.(js|css)?$
{
expires 1h;
}
}
#反向代理工程
location /b/ {
proxy_pass http://192.168.1.193:8080/b/;
#root C:\webapps\b; 當(dāng)使用純反向無法訪問工程時(shí)可以這幾個(gè)配置開啟
#proxy_redirect http://host:8080 http://$host:$server_port;
#index index.html index.htm;
}
#反向代理工程
location /a/ {
proxy_pass http://192.168.1.193:8080/a/;
#root C:\webapps\a;
#proxy_redirect http://host:8080 http://$host:$server_port;
#index index.html index.htm;
}
#訪問地址為http://localhost/a http://localhost/b
#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 {
root html;
}
看了以上關(guān)于nginx反向代理工程加入負(fù)載均衡及動(dòng)靜分離配置詳解,如果大家還有什么地方需要了解的可以在創(chuàng)新互聯(lián)行業(yè)資訊里查找自己感興趣的或者找我們的專業(yè)技術(shù)工程師解答的,創(chuàng)新互聯(lián)技術(shù)工程師在行業(yè)內(nèi)擁有十幾年的經(jīng)驗(yàn)了。
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
本文名稱:nginx反向代理工程加入負(fù)載均衡及動(dòng)靜分離配置詳解-創(chuàng)新互聯(lián)
瀏覽路徑:http://www.chinadenli.net/article30/dgecpo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)公司、面包屑導(dǎo)航、定制網(wǎng)站、全網(wǎng)營(yíng)銷推廣、網(wǎng)站設(shè)計(jì)、Google
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容