Docker nginx怎么安装与配置挂载
发表于:2024-10-19 作者:千家信息网编辑
千家信息网最后更新 2024年10月19日,这篇"Docker nginx怎么安装与配置挂载"文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来
千家信息网最后更新 2024年10月19日Docker nginx怎么安装与配置挂载
这篇"Docker nginx怎么安装与配置挂载"文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇"Docker nginx怎么安装与配置挂载"文章吧。
在docker下载nginx镜像
docker pull nginxdocker images
创建挂载目录
mkdir -p /data/nginx/{conf,conf.d,html,logs}
编写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; }}
启动容器
复制代码 代码如下:
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
查看启动的容器
docker ps
先前已经在docker部署两个tomcat,一个是8088端口,另一个是8089端口,并进入两个容器里编写了简单的页面
访问8088端口
访问8089端口
现在通过nginx访问两个tomcat的内容,实现负载均衡的功能,出于区别,更能体现负载均衡的功能,两个页面的内容不一样,但是访问路径都一样,只是通过nginx反向代理去轮换访问
以上就是关于"Docker nginx怎么安装与配置挂载"这篇文章的内容,相信大家都有了一定的了解,希望小编分享的内容对大家有帮助,若想了解更多相关的知识内容,请关注行业资讯频道。
内容
配置
两个
端口
容器
均衡
代码
功能
文件
文章
知识
篇文章
页面
价值
只是
大部分
就是
文件夹
更多
步骤
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
张槎深信服网络安全号
大王卡 免流服务器
如何修改jsp数据库
onenet平台创建数据库
泉州软件开发部经理
服务器加载好了
根服务器对国家网络安全的重要性
网络安全检查月报告
网络安全企业应对措施
无领导小组面试题网络安全
阿里软件中国网络技术有限公司
京东后台数据库
dw连接数据库代码
初学者学软件开发难吗
常见的网络安全分为几大类
数据库备份名称
天津本地软件开发批发价
应用对服务器要求
云邮箱服务器
一般网络安全工程师上班时间
进入服务器ip
室内地图软件开发
空间怎么启动数据库
移动网dns服务器是什么
涛翔网络技术有限公司怎么样
数据库上的安全软件有哪些
floor安装无法连接服务器
深圳嵌入式软件开发报价
网状数据库的结点
ogeek网络安全高手