2017-08-30 9 views
0

Nginxのバージョン1.10.2をCentOS 7 OSでホストされているリバースプロキシとして設定したいと思います。同じWildFly 10サーバーで複数のアプリケーションを実行しています。これらのアプリケーションは、http://213.xxx.xxx.xxx/app1http://213.xxx.xxx.xxx/app2にあります。 app2 http://app2.example.comのサブドメインを作成しました。私nginx.confファイルには、それらのサーバーが含まれていますNginxのサブドメインの設定が間違っています

server { 
    listen 80; 
    server_name example.com www.example.com; 
    location/{ 
     proxy_pass http://213.xxx.xxx.xxx/app1; 
    } 
} 

server { 
    listen 80; 
    server_name app2.example.com www.app2.example.com; 
    location/{ 
     proxy_set_header X-Forwarded-For $remote_addr; 
     proxy_set_header Host $host; 
     proxy_pass http://213.xxx.xxx.xxx/app2; 
    } 
} 

自分のWebブラウザから、私はURL example.comでAPP1に到達することができます。しかし、私はapp2に到達することはできません。 app2.example.comにリクエストを送信すると、app2.example.com/app2にリダイレクトされます。誰かが私の設定に間違っていることを教えてもらえますか?

+0

「app1.example.com」を使用すると同じことが起こりますか? –

+0

私はapp1のサブドメインを持っていませんが、app3と同じです。 – cheb1k4

+0

私は 'proxy_pass http://213.xxx.xxx.xxx/app1;'を変更することができます。 'app2.example.com'が' app1'を読み込むかどうかを確認してください。 –

答えて

0

あなたがアプリであるように、リダイレクトが行われるため、app1が動作しapp2が機能しないのはこのためです。今すぐ試すことができるものはほとんどありません

server { 
    listen 80; 
    server_name app2.example.com www.app2.example.com; 
    location/{ 
     proxy_set_header X-Forwarded-For $remote_addr; 
     proxy_set_header Host $host; 
     proxy_pass http://213.xxx.xxx.xxx/app2; 
     proxy_redirect http://213.xxx.xxx.xxx/app2/ http://$host/; 
    } 
} 
+0

同じ結果です。 – cheb1k4

+0

この記事に記載されている方法を使用してデバッグできますか? http://tarunlalwani.com/post/how-to-debug-nginx-reverse-proxy-issues-php-fpm-gunicorn-uwsgi/。詳細に質問の詳細を掲載する –

関連する問題