2017-01-19 13 views
0

ウェブアプリケーションのフロントエンドとしてnginxのコンテナが使用されています。nginx複数の場所とルートの内部

これは私の設定ファイルである:私は、ローカルホストを指している場合

server { 
    listen  80; 
    server_name localhost; 

    #charset koi8-r; 
    #access_log /var/log/nginx/log/host.access.log main; 

    root /usr/share/nginx/html/shaka-player-master/demo; 
    index index.html index.htm; 


    #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 /usr/share/nginx/html; 
    } 

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80 
    # 
    #location ~ \.php$ { 
    # proxy_pass http://127.0.0.1; 
    #} 

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 
    # 
    #location ~ \.php$ { 
    # root   html; 
    # fastcgi_pass 127.0.0.1:9000; 
    # fastcgi_index index.php; 
    # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 
    # include  fastcgi_params; 
    #} 


    # deny access to .htaccess files, if Apache's document root 
    # concurs with nginx's one 
    # 
    #location ~ /\.ht { 
    # deny all; 
    #} 
} 

:ポートは、それが/usr/share/nginx/html/shaka-player-master/demo/index.html正しく私を返します。.. 。

/usr/share/nginx/html/shaka-player-master/third_party/closure/goog/base.js 
/usr/share/nginx/html/shaka-player-master/dist/deps.js 
/usr/share/nginx/html/shaka-player-master/shaka-player.uncompiled.js 

このアプリケーション、ダッシュライブラリは、私がホストされている「deps.js」、base.jsなどをファイル名を生成するPythonスクリプトを実行必要がありますが、私は問題を抱えていますこれらのファイルは、これらのフォルダ内にありますしかし、ブラウザーは404を返します。なぜなら、これらの内容を設定ファイルから公開する方法がわからないからです。

私のようないくつかのコードを追加してみました:

location = third_party/closure/goog/base.js { 

root /usr/share/nginx/html/shaka-player-master/third_party/closure/goog/base.js; 
} 

しかし、まだ404

誰も私を助けることができますか?

+0

これらの3つのファイル - URIは何ですか? 'location'と'ルート '指示文を作成するには、その情報が必要です。 URIをパス名に効果的にマッピングします。 –

+0

GET http:// localhost:9900/third_party/closure/goog/base.jsこれらの3つのリソースに対して、ブラウザは次の要求を行います。 GET http:// localhost:9900/dist/deps.js GET http: //localhost:9900/shaka-player.uncompiled.js – pier92

+0

質問を編集して情報を追加する必要があります。コメントには表示されませんでした –

答えて

1

正しいlocationroot構文は次のようになります。

location = /third_party/closure/goog/base.js { 
    root /usr/share/nginx/html/shaka-player-master; 
} 
location = /dist/deps.js { 
    root /usr/share/nginx/html/shaka-player-master; 
} 
location = /shaka-player.uncompiled.js { 
    root /usr/share/nginx/html/shaka-player-master; 
} 

は詳細についてはlocationrootマニュアルページを参照してください。

このルートをデフォルトにして、デモの場所を例外にする設定もあります。

しかし、もう1つの潜在的な問題があります。アプリケーションがサーバー名としてlocalhost:9900を使用しているのはなぜですか?

+0

ソリューションをありがとうございました。 localhost:9900このnginxのコンテナはコンテナのポート80にあり、host'port 9900に公開しています。 – pier92

+0

関連する問題をここに追加しました:http://stackoverflow.com/questions/41741603/nginx-as-load-バランサー - アップストリーム - パス – pier92

関連する問題