2016-05-03 15 views
0

私は2つのnode.jsアプリケーションを持っています:1つは私のサイトで、もう1つはCIツールです。私は、次のnginxの設定を持っている:私はexample.comを開くとnode.jsのNginxプロキシエラー:リソースのロードに失敗しました

server { 
    listen 80; 

    server_name example.com; 

    location/{ 
     proxy_pass http://127.0.0.1:8081/; 
    } 

    location /ci { 
     rewrite ^/ci(.*) /$1 break; 
     proxy_pass http://127.0.0.1:3000/; 
    } 
} 

は、ブラウザでは正常にindex.htmlが、私はexample.com/ci開いたときに、それが唯一のindex.htmlと私負荷によって要求されたすべてのリソースをロードしますこれらのようなエラーを得た:

GET http://example.com/styles/styles.css  404 
GET http://example.com/scripts/app.js  404 

を私はCIのアプリでのindex.htmlの頭の中に<base href="/ci">が追加されているが、それは解決しません。

答えて

0

私は次のnginxの設定になってしまった:io.connect('http://example.com:3000'):私はsocket.io接続用のドメインとポートを指定し、私のCIアプリのクライアント側にも

server { 
    listen 80; 

    server_name example.com; 

    location/{ 
     if ($http_referer ~* example.com/ci) { 
      rewrite (.*) http://example.com/ci$1; 
     } 

     access_log off; 

     proxy_pass http://127.0.0.1:8081/; 
     proxy_set_header Host $host; 
     proxy_buffering off; 

     proxy_http_version 1.1; 
     proxy_set_header Upgrade $http_upgrade; 
     proxy_set_header Connection "upgrade"; 
    } 

    location = /ci { rewrite^/ci/ last; } 
    location /ci/ { 
     access_log off; 

     proxy_pass http://127.0.0.1:3000/; 
     proxy_set_header Host $host; 
     proxy_buffering off; 

     proxy_http_version 1.1; 
     proxy_set_header Upgrade $http_upgrade; 
     proxy_set_header Connection "upgrade"; 
    } 
} 

。 いいえ<base> HTMLタグが必要です。

+0

この設定では、http://example.com/ciからのすべてのPOST要求がGETに変わり、これを修正する方法がわかりません。 –

関連する問題