精品专区-精品自拍9-精品自拍三级乱伦-精品自拍视频-精品自拍视频曝光-精品自拍小视频

網站建設資訊

NEWS

網站建設資訊

Docker如何使用nginx搭建tomcat集群(圖文詳解)

服務器

首先創建tomcat的文件夾 ,為了方便docker的配置 我這里直接在根目錄中創建第一步:創建文件夾:發布文件夾

成都創新互聯公司專注于蒲江縣網站建設服務及定制,我們擁有豐富的企業做網站經驗。 熱誠為您提供蒲江縣營銷型網站建設,蒲江縣網站制作、蒲江縣網頁設計、蒲江縣網站官網定制、微信小程序開發服務,打造蒲江縣網絡公司原創品牌,更為您提供蒲江縣網站排名全網營銷落地服務。
mkdir -p /docker/tomcat/webapp8081

mkdir -p /docker/tomcat/webapp8082

mkdir -p /docker/tomcat/webapp8083

第二步:創建Tomcat容器(端口 可以根據自己的實際更換)

docker run -d --name tomcat8081 -p 8081:8080 -v /docker/tomcat/webapp8081:/usr/local/tomcat/webapps/ tomcat
docker run -d --name tomcat8082 -p 8082:8080 -v /docker/tomcat/webapp8082:/usr/local/tomcat/webapps/ tomcat
docker run -d --name tomcat8083 -p 8083:8080 -v /docker/tomcat/webapp8083:/usr/local/tomcat/webapps/ tomcat

創建完成后使用 docker ps 命令進行查看是否創建成功 并且使用

第三步:查看tomcat的IP 使用命令依次查詢 這里只使用第一個舉例

docker inspect tomcat8081

第四步:為了方便測試 我這里就不上傳war包了,直接 在里面創建了一個hello/index.html 文件

注意:如果Nginx為Docker容器,必須使用Tomact容器IP,否則連不上

首先在官網上下載nginx的官方版本

官網:http://nginx.org/en/

點擊右邊導航欄的download,進入下載界面 選擇對應的版本 進行下載,我這里就使用nginx-1.6.2.tar

下載完成后,將文件放到自定義的文件夾,我這里放到/usr/local/tools/nginx-1.6.2

使用 這個命令將nginx 解壓:

tar vxf nginx-1.6.2.tar.gz

解壓完成后,我這里是返回根目錄,在根目錄創建一個宿主文件夾,目的是為了創建文件,使得nginx可以掛載(你也可以自定義)

創建宿主文件夾 這里

mkdir -p /docker/nginx/
vim /docker/nginx/nginx.conf
mkdir -p /docker/nginx/html

拷貝頁面你解壓的negix中的html文件夾中的index.html 50x.html到/docker/nginx/html文件夾中

這里提供一種negix的conf文件,以為加上注解 所以格式可能會發生改變 記得把注解刪了

Nginx.conf:

user root;

worker_processes 2; #這里設置你的線程數

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024; #連接數量
}
http {
include mime.types;
default_type application/octet-stream;
upstream mytomcat{
server 172.17.0.3:8080 weight=10;
# 另外mytomcat 這里名字和下方的名字保持一致 這里需要和你的tomcat IP保持一致
server 172.17.0.4:8080 weight=50;
server 172.17.0.5:8080 weight=10;
}
#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 logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name mytomcat;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
# root html;
# index index.html index.htm;
proxy_connect_timeout 50;
proxy_read_timeout 10;
proxy_send_timeout 20;
proxy_pass http://mytomcat;
}
#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;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \\.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \\.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache\'s document root
# concurs with nginx\'s one
#
#location ~ /\\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}

使用docker 啟動

創建并運行容器

81:是外網訪問的端口 這里可以根據實際做修改

/docker/nginx/nginx.conf 本地的宿主文件

/etc/nginx/nginx.conf 解壓的目錄(也可以不更改)

/docker/nginx/html 本地的宿主文件

/usr/share/nginx/html 解壓的目錄

docker run -d --name nginx81 -p 81:80 -v /docker/nginx/nginx.conf:/etc/nginx/nginx.conf -v /docker/nginx/html:/usr/share/nginx/html nginx

測試

http://39.106.147.162:8085/hello/index.html 我這里配置的是8085端口

直接訪問

總結

以上所述是小編給大家介紹的Docker使用nginx搭建tomcat集群的教程,希望對大家有所幫助!


文章標題:Docker如何使用nginx搭建tomcat集群(圖文詳解)
標題鏈接:http://m.jcarcd.cn/article/cjpipc.html
主站蜘蛛池模板: 国产乱轮精品一区 | 欧美小视频在线 | 91网在线观看| 91网页版| 日韩欧美激情视频 | 97国产在线公开免 | 无码av天堂一区二区三区 | 国产日产欧产美韩 | 国产精品中文久 | 国产激情中文在线 | 国产亚洲欧美日 | 青青草欧美 | 中文字幕欧美第一页 | 韩国理伦电影三级 | 日韩视频一区 | 成人羞羞免 | 欧美日韩一区四区 | 国产大片黄在线观看 | 欧美一级大黄特黄 | 91探花国产综合在 | 国产区图片 | 午夜福利导航免费 | 成人极品影院 | 欧美日韩国产首页 | 日韩在线播放专区 | 中文字幕国产欧美 | 91午夜视频在线 | 国产精品高清另 | 日韩午夜基地 | 国产精品福利在线观 | 精品国精品国 | 国产丝袜在线播放 | 精品国产三 | 国产精品太长太粗太 | 91免费在| 精品午夜福 | 国产丝袜视频在 | 国产精品三级 | 国语自产视频在线 | 午夜成人影视神马 | 成人激情受网点 |