zoukankan      html  css  js  c++  java
  • 5.动静分离

    动态资源代理

    location / {
      proxy_pass 路径;
    }
    

    静态资源代理

    location / {
      root 静态资源路径;
      index 默认访问路径下的什么资源;
      autoindex on; # 带表展示静态资源下的全部内容,以列表的形式展示。
      expires 1d;   # 为客户端设置静态资源缓存时间
    }
    
    
    # 先修改docker,添加数据卷,映射到nginx服务器的一个目录
    [root@localhost docker_nginx]# vi docker-compose.yml
    
    volumes:
          - /opt/docker_nginx/conf.d:/etc/nginx/conf.d
          - /opt/docker_nginx/img:/data/img    # 映射存放图片的目录
          - /opt/decker_nginx/html:/data/html  # 存放静态页面的目录
          
    [root@localhost docker_nginx]# docker-compose down   # 先删除容器
    [root@localhost docker_nginx]# docker-compose up -d  # 再启动容器
    
    [root@localhost html]# vi index.html # 在静态资源目录下添加个页面
    <h1>hello static resource</h1>
    
    [root@localhost img]# ls  # 在img存放一张图片
    1.jpg
    
    
    server{
      listen 80;
      server_name localhost;
    
      location /html {
        root /data;
        index index.html;
      }
    
      location /img {
        root /data;
        autoindex on;
      }
    }
    
    docker-compose restart
    
  • 相关阅读:
    多项式的一些操作
    AtCoder Grand Contest 036E
    THUWC2017 随机二分图
    THUWC2017 在美妙的数学王国中畅游
    SDOI2017 切树游戏
    ZJOI2017 树状数组
    HNOI2015 接水果
    LOJ6503 Magic
    Charles 抓去app接口的使用
    mysql 字符串类型和数字对比的坑
  • 原文地址:https://www.cnblogs.com/eba001/p/14312327.html
Copyright © 2011-2022 走看看