国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > Nginx > 正文

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

2024-08-30 12:24:03
字體:
來源:轉載
供稿:網友

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

mkdir -p /docker/tomcat/webapp8081mkdir -p /docker/tomcat/webapp8082mkdir -p /docker/tomcat/webapp8083

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

docker run -d --name tomcat8081 -p 8081:8080 -v /docker/tomcat/webapp8081:/usr/local/tomcat/webapps/ tomcatdocker run -d --name tomcat8082 -p 8082:8080 -v /docker/tomcat/webapp8082:/usr/local/tomcat/webapps/ tomcatdocker 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.confmkdir -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;# }#}}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 宜兴市| 南华县| 阜南县| 屏边| 和硕县| 宁津县| 通江县| 黔南| 枝江市| 依兰县| 虎林市| 讷河市| 岢岚县| 平谷区| 满城县| 泽普县| 邵东县| 瑞安市| 南城县| 滦南县| 舒城县| 宝鸡市| 浑源县| 长沙市| 东丽区| 海晏县| 英超| 五大连池市| 奈曼旗| 苍山县| 平罗县| 浦县| 惠东县| 县级市| 来宾市| 阿拉善盟| 开阳县| 新乐市| 铜川市| 庆安县| 济阳县|