Docker怎樣部署nginx+tomcat

這期內(nèi)容當(dāng)中小編將會給大家?guī)碛嘘P(guān)Docker怎樣部署nginx + tomcat,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

創(chuàng)新互聯(lián)于2013年創(chuàng)立,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目網(wǎng)站設(shè)計(jì)制作、成都網(wǎng)站建設(shè)網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢想脫穎而出為使命,1280元青云譜做網(wǎng)站,已為上家服務(wù),為青云譜各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:13518219792

簡介

在生產(chǎn)環(huán)境中,很多企業(yè)會經(jīng)常使用nginx + tomcat 架構(gòu),nginx作為負(fù)載均衡器,反向代理,tomcat作為節(jié)點(diǎn)服務(wù)器。在docker容器中也可以使用這種架構(gòu)。
對這種架構(gòu)感興趣的可以參考博客:https://blog.51cto.com/13760351/2161850

操作環(huán)境

Docker怎樣部署nginx + tomcat

備注:實(shí)驗(yàn)中已關(guān)閉防火墻,打好企業(yè)使用的war包

部署過程:

一、安裝nginx鏡像

可參考博客 https://blog.51cto.com/13760351/2469063

二、部署war包項(xiàng)目

部署及排坑過程可參考博客 https://blog.51cto.com/13760351/2469305

三、修改nginx配置文件

vim /etc/nginx/nginx.conf

user  nginx;
worker_processes  1;
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/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" "$upstream_addr"';

    access_log  /var/log/nginx/access.log  main;
    sendfile        on;
    #tcp_nopush     on;
    keepalive_timeout  65;
    #gzip  on;
    upstream tomcat {
        server 47.99.150.153:8088 weight=1;  #添加權(quán)重
        server 47.99.150.155:8088 weight=1;
    }

    server {
        listen 80;
        server_name localhost;

                location / {
            root  /usr/share/nginx/html;
            index  index.html index.htm;
            }

        location /admin {
            proxy_pass http://tomcat;  #添加
            proxy_redirect off;
            index index.html index.htm;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Real-Port $remote_port;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }

    include /etc/nginx/conf.d/*.conf;
}

四、網(wǎng)頁驗(yàn)證

Docker怎樣部署nginx + tomcat

上述就是小編為大家分享的Docker怎樣部署nginx + tomcat了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

網(wǎng)頁題目:Docker怎樣部署nginx+tomcat
網(wǎng)站網(wǎng)址:http://bm7419.com/article28/pcdhjp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、商城網(wǎng)站、電子商務(wù)云服務(wù)器、網(wǎng)站策劃、品牌網(wǎng)站設(shè)計(jì)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

營銷型網(wǎng)站建設(shè)