首页  :: 新随笔  :: 管理

nginx基于目录的映射:

Posted on 2017-11-17 16:22  季枫  阅读(2339)  评论(0编辑  收藏  举报

nginx基于目录的映射:

   location /wxchat/ {
          #proxy_redirect off;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

          proxy_cookie_path  /xie_wechat /wechat;
          proxy_set_header   Cookie $http_cookie;

          proxy_pass http://10.8.0.9:8080/xie_wechat/;
          #proxy_set_header X-Forwarded-Proto https;
          proxy_redirect http:// $scheme://;

          #try_files $uri $uri/ /index.html;

             if ($request_method = 'OPTIONS') {
                add_header 'Access-Control-Allow-Origin' '*';
                add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';

                add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';

                add_header 'Access-Control-Max-Age' 1728000;
                add_header 'Content-Type' 'text/plain charset=UTF-8';
                add_header 'Content-Length' 0;
                return 204;
             }
             if ($request_method = 'POST') {
                add_header 'Access-Control-Allow-Origin' '*';
                add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
                add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
             }
             if ($request_method = 'GET') {
                add_header 'Access-Control-Allow-Origin' '*';
                add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
                add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
             }



          if ($request_filename ~* .*.(html|htm)$)
          {
            expires -1s;
          }
          if ($request_filename ~* .*.(gif|jpg|jpeg|png|bmp|swf)$)
          {
            expires -1s;
          }
          if ($request_filename ~ .*.(js|css)$)
          {
            expires -1s;
          }
    }

  

智读 | 成都会领科技有限公司官网 | 智读App下载 | 每天听本书的博客 | |