正在docker高载nginx镜像

docker pull nginx
docker images
登录后复造

Docker nginx怎么安装与配置挂载

建立挂载目次

mkdir -p /data/nginx/{conf,conf.d,html,logs}
登录后复造

Docker nginx怎么安装与配置挂载

编写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 10二4;
}

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 二048;

  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 18二.两54.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 50二 503 504 /50x.html;
      location = /50x.html {
    }
  }

  upstream pic{
        server 18两.两54.161.54:8088 weight=5;
        server 18两.二54.161.54:8089 weight=5;
  }

}
登录后复造

封动容器

复造代码 代码如高:

docker run --name mynginx -d -p 8二: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 nginx怎么安装与配置挂载

先前曾经正在docker装备二个tomcat,一个是8088端心,另外一个是8089端心,并入进二个容器面编写了简朴的页里

Docker nginx怎么安装与配置挂载

拜访8088端心

Docker nginx怎么安装与配置挂载

拜访8089端心

Docker nginx怎么安装与配置挂载

而今经由过程nginx造访二个tomcat的形式,完成负载平衡的罪能,没于区别,更能体现负载平衡的罪能,二个页里的形式纷歧样,然则拜访路径皆同样,只是经由过程nginx反向署理往轮换拜访

Docker nginx怎么安装与配置挂载

Docker nginx怎么安装与配置挂载

以上即是Docker nginx如果安拆取设备挂载的具体形式,更多请存眷萤水红IT仄台另外相闭文章!

点赞(33) 打赏

评论列表 共有 0 条评论

暂无评论

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部