1. 配置Nginx转发
    2. #创建文件夹
    3. mkdir -p /opt/nginx/conf /opt/nginx/html /opt/nginx/logs
    4. #新建配置文件
    5. vim nginx/conf/nginx.conf
    6. #配置文件内写入
    7. worker_processes 1;
    8. events{
    9. worker_connections 1024;
    10. }
    11. http{
    12. include mime.types;
    13. default_type application/octet-stream;
    14. sendfile on;
    15. keepalive_timeout 65;
    16. upstream node{
    17. server 127.0.0.1:8080;
    18. server 127.0.0.1:8081;
    19. server 127.0.0.1:8082;
    20. }
    21. server{
    22. listen 80;
    23. server_name localhost;
    24. location / {
    25. #proxy_pass http://127.0.0.1:8080;
    26. #负载均衡配置
    27. proxy_pass http://node
    28. }
    29. }
    30. }
    31. 最后启动docker
    32. 负载均衡可以用docker_compose