對這種架構(gòu)感興趣的可以參考博客:https://blog.51cto.com/13760351/2161850

操作環(huán)境

備注:實(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)證

更多關(guān)于云服務(wù)器域名注冊,虛擬主機(jī)的問題,請?jiān)L問三五互聯(lián)官網(wǎng):m.shinetop.cn

贊(0)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享網(wǎng)絡(luò)內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。郵箱:3140448839@qq.com。本站原創(chuàng)內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明出處:三五互聯(lián)知識庫 » Docker 部署 nginx tomcat

登錄

找回密碼

注冊