thr.vchangyi.com.conf 2.29 KB
server {
    listen 80;
    error_log  /data/wwwlogs/qy.nginx_error.log error;
    server_name thr.vchangyi.com;
    index index.html index.htm index.php;
    root /data/wwwroot/thr.vchangyi.com/www;
    location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|thumb|xml|swf|txt|woff|ttf|eot|svg|otf|htm|html|apk|map)$ {
        # 微信前端 h5
        if ($request_uri ~ ^/([^/]+)/([^/]+)/h5/index.html) {
            rewrite ^/([^/]+)/([^/]+)/h5 /$2/h5/index.html break;
        }

        if ($request_uri ~ ^/([^/]+)/([^/]+)/h5/index-dev.html) {
            rewrite ^/([^/]+)/([^/]+)/h5 /$2/h5/index-dev.html break;
        }

        if ($request_uri ~ ^/([^/]+)/([^/]+)/h5/(.*)(jpg|jpeg|gif|css|png|js|ico|thumb|xml|swf|txt|woff|ttf|eot|svg|otf|apk)) {
            rewrite ^/([^/]+)/([^/]+)/h5/(.*) /$2/h5/$3 break;
        }

        access_log /dev/null;
        expires 10d;
    }

    location / {
        index index.html index.htm index.php;
        access_log /data/wwwlogs/thr.vchangyi.com-access.log combined buffer=32k;

        if ($request_uri ~ ^/([^/]+)/([^/]+)/h5) {
            rewrite ^/([^/]+)/([^/]+)/h5 /$2/h5/index.html break;
        }

        if ($request_uri ~ ^/admincp) {
            rewrite ^/admincp /admincp/index.html break;
        }

        if (!-e $request_filename) {
            rewrite ^/(.*)$ /index.php last;
            break;
        }
    }

    location ~ [^/]\.php(/|$) {
        try_files $uri =404;
        chunked_transfer_encoding off;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;

        # 设置 PATH_INFO 并改写 SCRIPT_FILENAME, SCRIPT_NAME 服务器环境变量
        set $path_info "";
        set $real_script_name $fastcgi_script_name;
        if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") {
            set $real_script_name $1;
            set $path_info $2;
        }

        fastcgi_param PATH_INFO $path_info;
        fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
        fastcgi_param SCRIPT_NAME $real_script_name;
    }

    location /nginx_status {
        stub_status on;
        access_log off;
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
        expires 30d;
    }

    location ~ .*\.(js|css)?$ {
        expires 12h;
    }

    access_log /data/wwwlogs/thr.vchangyi.com-access.log access;
}