2017-05-05 12 views
0

nginxには2つのサーバー(ポート80と443)が稼働しています。これらのproxy_pass私たちの上流:Nginx on 443、ノードハンドリングSSL証明書

upstream app_nodes { 
     ip_hash; 
     server 127.0.0.1:3000; 
     server 127.0.0.1:3001; 
    } 

    upstream app_nodes_https { 
     ip_hash; 
     server 127.0.0.1:8000; 
     server 127.0.0.1:8001; 
    } 

ポート80では、これは問題ありません。しかし、443では、nginx内でssl certsが定義されていないため、これは失敗します。多くのドメインを動的にサポートするために証明書を処理するには、node.jsアプリケーション(ポート8000​​/8001でリッスンする)が必要です。

nginxにアップストリームサーバを単にプロキシしてsslを処理させる方法はありますか?

はあなたに

EDITありがとう:ここではnginx -tを行う443

server { 
     listen 443; 

     gzip on; 
     gzip_types text/plain application/json application/ocet-stream; 

     location/{ 
      proxy_pass  https://app_nodes_https;  
      add_header  X-Upstream $upstream_addr; 
      add_header  X-Real-IP $remote_addr;  
      include   /etc/nginx/proxy_params; 
     } 

} 

のための私達のサーバブロックは、実際には解決策がストリームを使用することであるhttps protocol requires SSL support

+0

nginxがSSLエンドポイントでない場合、トラフィックのHTTP部分を調べることができないので、ロードバランシングにプレーンTCPを使用する必要があります。 [nginx load balancing - tcpおよびudp load balancer](https://www.nginx.com/resources/admin-guide/tcp-load-balancing/)を参照してください。 –

+0

これはTCPがデフォルトであると言います。おそらく 'listen 443 'です。これはTCP – dzm

答えて

0

というエラーを与えています:

stream { 
     upstream https_stream { 
      hash $remote_addr; 
      server 127.0.0.1:8000; 
      server 127.0.0.1:8001; 
     } 
     server { 
      listen 443; 
      proxy_pass https_stream; 
     } 
} 

これはあなたの稼動を前提としています8000/8001のアプリインスタンス