制作镜像:
FROM alpine MAINTAINER don RUN apk --update add nginx COPY nginx.conf /etc/nginx/nginx.conf EXPOSE 80 CMD ["nginx","-g","daemon off;"]
容器80端口映射成host的50448,host ip是 52.82.52.63,浏览器里输入的内容:http://52.82.52.63:50448/
upstream zp_server1{ server 52.82.52.63:50449; } server { listen 80; server_name 52.82.52.63; location / { proxy_pass http://zp_server1; } }
=================负载均衡示例,共发起了1000个请求,两个应用各收到500个
events { # The maximum number of simultaneous connections that can be opened by # a worker process. multi_accept on; use epoll; worker_connections 1024; } upstream zp_server1{ server 52.82.52.63:50449; server 52.82.52.63:50447; } server { listen 80; server_name 52.82.52.63; location / { proxy_pass http://zp_server1; } }
curl -v http://www.imooc.com >dev/null
============下面第一条是检查配置文件是否有语法问题;第二句是重新加载配置文件
====================nginx模块讲解
============配置语法
通过ab工具进行压力测试
==========访问控制=====
通过http://www.ip138.com/查询出口ip,公网通过138查询,内网实验环境通过ipconfig就能查询到
局限性的解决办法:
需要输入密码才能访问