nignx作为文件服务器免密访问

以docker中通过容器创建的nginx进行讲解

[root@iZ2zeddfxu8dZ conf]# pwd
/data/nginx8099/conf
[root@iZ2zeddfxu8dZ conf]# ll
total 4
-rw-r--r-- 1 root root 3602 Jun 12 14:55 nginx.conf

打开nginx.conf文件

location /images {
              alias  /usr/share/nginx/file;  #这里的路径都是容器内部的路径
        }
#上面这种方式是在创建nginx8099容器的时候,将本地文件路径/data/nginx8099/file 映射到容器内的目录/usr/share/nginx/file;只需把文件放到data/nginx8099/file目录下。通过http://ip地址:端口/images/uploadFile.html 就可以访问。

location / {
          index index.html index.htm;
          root  /usr/share/nginx/html;  #这里的路径都是容器内部的路径
          error_page 404 /index.html;
  }
  #这种方式是把文件放到容器内部路径/usr/share/nginx/html对应的本地路径/data/nginx8099/html下。
  然后通过http://ip地址:端口/uploadFile.html 访问。nginx容器都不用重启。
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值