记录一下,项目当中使用的nginx配置(本地启动)

#user  nobody;
 worker_processes  1;#error_log  logs/error.log;
 #error_log  logs/error.log  notice;
 #error_log  logs/error.log  info;#pid        logs/nginx.pid;
 events {
     worker_connections  1024;
 }http {
     include       mime.types;
     default_type  application/octet-stream;    #access_log  logs/access.log  main;
    sendfile        on;
     #tcp_nopush     on;    #keepalive_timeout  0;
     keepalive_timeout  65;    #gzip  on;
    server {
         listen       9000;
         
         server_name      www.unisiot.com;
         #server_name      ~^((?<subdomain>.*)\.)?unisiot\.com$;
         if ($subdomain = ""){
            set $subdomain "www";
         }
     
         index        index.html index.htm;        #charset koi8-r;
        #access_log  logs/host.access.log  main;
         
         ssi on;
         ssi_silent_errors on;
         #ssi_types text/shtml;
         expires 30d;
         
         location / {
         
             root   F:/mainsite_root/mainsite/$dns;
             index   index.html index.htm;
            
             if ($host ~ (^\S*?(?=\.\S*))){
                 set $dns $1;
             }
             #alias F:/mainsite_root/mainsite/$dns;
             #index index.html;
            
             #判断终端
             if ($http_user_agent ~* '(Android|webOS|iPhone|iPod|BlackBerry|iPad)') {
                set $mobile_request '1';
                #如果访问UA为移动终端类型则判断为mobile_request=1
             }
             if ($http_cookie ~ 'mobile_request=full') {
                set $mobile_request '';
             }
             if ($mobile_request = '') {
                #proxy_pass http://139.196.188.213;
                #判断mobile_request等于空则为PC终端
                root   F:/mainsite_root/mainsite/$dns/web;
             }
         
             #break;
             
             if ($uri ~* '(lobby|bedroom|livingroom|lavatory|kitchen|videoroom)') {
                 root   F:/mainsite_root/mainsite/$dns;
             }
         }
         
         location /commonHtml {
             alias   F:/mainsite_root/common/;     
         }
         
         location /$subdomain {
             alias   F:/mainsite_root/mainsite/$subdomain;     
         }
         
         location ~ ^/(BJUI|ckeditor4.8|common|images|js|nice-validator|www|static)/ {
             root   F:/mainsite_root/static;
             autoindex on;
             access_log  off;
             expires     30d;          
         }
         
         location ~ ^/(upload)/ {
             root   F:/mainsite_root/;
             autoindex on;
             access_log  off;
             expires     30d;          
         }
         
         #error_page  404              /404.html;
         # redirect server error pages to the static page /50x.html
         #
         error_page   500 502 503 504  /50x.html;
         location = /50x.html {
             root   html;
         }
     }
 }

完结!