docker安装nginx

docker 下载nginx
[root@VM-0-14-centos home]# docker redis
docker: 'redis' is not a docker command.
See 'docker --help'
[root@VM-0-14-centos home]# docker pull redis
Using default tag: latest
latest: Pulling from library/redis
33847f680f63: Already exists 
26a746039521: Pull complete 
18d87da94363: Pull complete 
5e118a708802: Pull complete 
ecf0dbe7c357: Pull complete 
46f280ba52da: Pull complete 
Digest: sha256:cd0c68c5479f2db4b9e2c5fbfdb7a8acb77625322dd5b474578515422d3ddb59
Status: Downloaded newer image for redis:latest
docker.io/library/redis:latest

启动
# -d 后台运行
# --name 给容器命名
# -p 宿主机端口:容器内部端口
[root@VM-0-14-centos home]# docker run -d --name nginx01 -p 39001:80 nginx
449c6adeacf271331603497c9401b5fa536a5b165a39e7cbd54952707205da85
[root@VM-0-14-centos home]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS                                     NAMES
449c6adeacf2   nginx     "/docker-entrypoint.…"   7 seconds ago    Up 5 seconds    0.0.0.0:39001->80/tcp, :::39001->80/tcp   nginx01
58778b7576e5   centos    "/bin/bash"              56 minutes ago   Up 56 minutes                                             angry_chebyshev
[root@VM-0-14-centos home]# curl localhost:39001
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
[root@VM-0-14-centos home]# docker exec -it nginx01 /bin/bash
root@449c6adeacf2:/# whereis nginx
nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx
root@449c6adeacf2:/# cd /etc/nginx
root@449c6adeacf2:/etc/nginx# ls
conf.d	fastcgi_params	mime.typ
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
借助淘宝技术团队开发的nginx模快nginx_upstream_check_module来检测后方realserver的健康状态,如果后端服务器不可用,则会将其踢出upstream,所有的请求不转发到这台服务器。当期恢复正常时,将其加入upstream。 nginx_upstream_check_module健康检查的时间间隔是毫秒级,而且可以自定义监控url,定制监控页,响应速度快,比原生的敏感度要高。 Syntax: check interval=milliseconds [fall=count] [rise=count] [timeout=milliseconds] [default_down=true|false] [type=tcp|http|ssl_hello|mysql|ajp] [port=check_port] Default: 如果没有配置参数,默认值是:interval=30000 fall=5 rise=2 timeout=1000 default_down=true type=tcp Context: upstream 该指令可以打开后端服务器的健康检查功能。指令后面的参数意义是: interval:向后端发送的健康检查包的间隔,单位为毫秒。 fall(fall_count): 如果连续失败次数达到fall_count,服务器就被认为是down。 rise(rise_count): 如果连续成功次数达到rise_count,服务器就被认为是up。 timeout: 后端健康请求的超时时间,单位毫秒。 default_down: 设定初始时服务器的状态,如果是true,就说明默认是down的,如果是false,就是up的。默认值是true,也就是一开始服务器认为是不可用,要等健康检查包达到一定成功次数以后才会被认为是健康的。 type:健康检查包的类型,现在支持以下多种类型: tcp:简单的tcp连接,如果连接成功,就说明后端正常。 ssl_hello:发送一个初始的SSL hello包并接受服务器的SSL hello包。 http:发送HTTP请求,通过后端的回复包的状态来判断后端是否存活。 mysql: 向mysql服务器连接,通过接收服务器的greeting包来判断后端是否存活。 ajp:向后端发送AJP协议的Cping包,通过接收Cpong包来判断后端是否存活。 port: 指定后端服务器的检查端口。你可以指定不同于真实服务的后端服务器的端口,比如后端提供的是443端口的应用,你可以去检查80端口的状态来判断后端健康状况。默认是0,表示跟后端server提供真实服务的端口一样。该选项出现于Tengine-1.4.0。 Syntax: check_keepalive_requests request_num Default: 1 Context: upstream 该指令可以配置一个连接发送的请求数,其默认值为1,表示Tengine完成1次请求后即关闭连接。 Syntax: check_http_send http_packet Default: "GET / HTTP/1.0\r\n\r\n" Context: upstream 该指令可以配置http健康检查包发送的请求内容。为了减少传输数据量,推荐采用"HEAD"方法。 当采用长连接进行健康检查时,需在该指令中添加keep-alive请求头,如:"HEAD / HTTP/1.1\r\nConnection: keep-alive\r\n\r\n"。 同时,在采用"GET"方法的情况下,请求uri的size不宜过大,确保可以在1个interval内传输完成,否则会被健康检查模块视为后端服务器或网络异常。 Syntax: check_http_expect_alive [ http_2xx | http_3xx | http_4xx | http_5xx ] Default: http_2xx | http_3xx Context: upstream 该指令指定HTTP回复的成功状态,默认认为2XX和3XX的状态是健康的。 效果: 访问:https://*****/nstatus

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值