Docker下载nginx镜像


Nginx

1.Nginx反向代理:

1.Docker下载nginx镜像

注意:nginx的挂载比较特殊:

需要先运行起来,然后把容器内的配置文件拷贝到当前的目录,关闭并移除nginx,重新运行并挂载目录文件。

1.运行nginx,没有则自动下载

docker run -p 8090:80 --name nginx  -d nginx

2.将容器内的配置文件拷贝到当前目录:

docker container cp nginx:/etc/nginx .

3.修改nginx 名称为conf,并创建新的nginx文件

mv nginx conf

4.移动conf到nginx/ 目录

mv conf nginx/

5.重新运行nginx

docker run -p 8090:80 --name nginx \
  -v ~/mydata/nginx/html:/usr/share/nginx/html \
  -v ~/mydata/nginx/conf:/etc/nginx \
  -v ~/mydata/nginx/logs:/var/log/nginx \
  -d nginx

2.测试nginx反向代理

1.在html文件夹下创建 index.html 文件,注意一是 index.html 文件。因为default.conf文件下配置的为index.html,若要改成a.html则需要修改文件并重启nginx服务。

2.写上内容,并打开浏览器访问 http://localhost:8090/ 进行测试。

3.Nginx部署多个springboot项目

https://blog.csdn.net/weixin_35688029/article/details/81773300

2.Nginx负载均衡

1.首先在nginx.conf文件的http中添加:

upstream myserver{
        server 本机ip:8080 weight=1;
        server 本机ip:8081 weight=1;
    }

2.在location中添加:

location / {
        proxy_pass http://myserver;
    }

3.Nginx中文网站

https://www.nginx.cn/doc/example/loadbanlance.html

nginx动静分离

nginx高可用


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM