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容器都不用重启。

猜你喜欢

转载自blog.csdn.net/adminstate/article/details/131174866