nginx为nodeJS配置静态资源SeaJS-combo


想用nginx做反向代理,代理上游为nodeJS程序,如果想要配置静态资源combo服务应该要怎样

配置如下:

情况一
配置:


 server {
        listen       5555;
        server_name  172.16.42.97;

        location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$
        {
            root /usr/local/nginx/html;
            index  index.html;
            concat on;                      
            concat_max_files 20;            
            concat_unique on;               
            concat_types "application/javascript" "text/css";
        }
        location /
        {
            proxy_pass http://172.16.42.97:4000/;
        }
    }

报错502。

情况二
配置:


 server {
        listen       5555;
        server_name  172.16.42.97;

        location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$
        {
            root /usr/local/nginx/html;
            index  index.html;
            concat on;                      
            concat_max_files 20;            
            concat_unique on;               
            concat_types "application/javascript" "text/css";
        }
    }

报错Uncaught SyntaxError: Unexpected token <
combo合成失败

情况三
配置:


 server {
        listen       5555;
        server_name  172.16.42.97;

        location /
        {
            root /usr/local/nginx/html;
            index  index.html;
            concat on;                      
            concat_max_files 20;           
            concat_unique on;              
            concat_types "application/javascript" "text/css"; 
        }

正常没问题。

node.js nginx

Lyricus 9 years, 3 months ago

直接


 location / {
    proxy_pass http://172.16.42.97:4000/;
}

把非静态资源请求全部扔过去就行了,不用什么表达式。

H魔朮禁睩 answered 9 years, 3 months ago

Your Answer