node.js - nginx为nodeJS配置静态资源SeaJS-combo
PHPz
PHPz 2017-04-17 12:00:45
0
2
657

想用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"; 
        }

正常没问题。

PHPz
PHPz

学习是最好的投资!

全部回覆(2)
巴扎黑

直接

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

把非靜態資源請求全部丟過去就行了,不用什麼表達式。

PHPzhong

雷雷

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!