小編給大家分享一下Docker中nginx如何安裝與配置掛載,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!
創(chuàng)新互聯(lián)是專(zhuān)業(yè)的隴南網(wǎng)站建設(shè)公司,隴南接單;提供成都做網(wǎng)站、成都網(wǎng)站建設(shè),網(wǎng)頁(yè)設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專(zhuān)業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行隴南網(wǎng)站開(kāi)發(fā)網(wǎng)頁(yè)制作和功能擴(kuò)展;專(zhuān)業(yè)做搜索引擎喜愛(ài)的網(wǎng)站,專(zhuān)業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來(lái)合作!在Docker下載Nginx鏡像
docker pull nginx docker images
創(chuàng)建掛載目錄
mkdir -p /data/nginx/{conf,conf.d,html,logs}
編寫(xiě)nginx,conf配置文件,并放在文件夾中
# For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { 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 /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; server { listen 80 default_server; listen [::]:80 default_server; server_name 182.254.161.54; root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { proxy_pass http://pic; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } upstream pic{ server 182.254.161.54:8088 weight=5; server 182.254.161.54:8089 weight=5; } }
啟動(dòng)容器
復(fù)制代碼 代碼如下:
docker run --name mynginx -d -p 82:80 -v /data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /data/nginx/logs:/var/log/nginx -d docker.io/nginx
查看啟動(dòng)的容器
docker ps
先前已經(jīng)在Docker部署兩個(gè)tomcat,一個(gè)是8088端口,另一個(gè)是8089端口,并進(jìn)入兩個(gè)容器里編寫(xiě)了簡(jiǎn)單的頁(yè)面
訪問(wèn)8088端口
訪問(wèn)8089端口
現(xiàn)在通過(guò)Nginx訪問(wèn)兩個(gè)tomcat的內(nèi)容,實(shí)現(xiàn)負(fù)載均衡的功能,出于區(qū)別,更能體現(xiàn)負(fù)載均衡的功能,兩個(gè)頁(yè)面的內(nèi)容不一樣,但是訪問(wèn)路徑都一樣,只是通過(guò)Nginx反向代理去輪換訪問(wèn)
看完了這篇文章,相信你對(duì)“Docker中nginx如何安裝與配置掛載”有了一定的了解,如果想了解更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!
當(dāng)前題目:Docker中nginx如何安裝與配置掛載-創(chuàng)新互聯(lián)
轉(zhuǎn)載源于:http://muchs.cn/article34/doogpe.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開(kāi)發(fā)、動(dòng)態(tài)網(wǎng)站、全網(wǎng)營(yíng)銷(xiāo)推廣、網(wǎng)站設(shè)計(jì)公司、網(wǎng)站營(yíng)銷(xiāo)、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í)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容