私はhttp://www.example.comウェブサイトで働いているUbuntu Node.jsサーバーを持っていました。 私はhttp:// localhost:3000を使ってテストを行いましたが、Ubuntuにデプロイしたときには、 まだポート(www.example.com:3000)を入力しなければなりませんでした。ポート3000要件を削除するために逆プロキシ を実装するように指示されました。私はnginxをインストールし、 を次のように追加しました。 sudo nano/etc/nginx/sites-available/default ----------すべて削除してからコピー/ペースト----------- ---------------httpからhttpsにnginxを設定するには
server {
listen 80;
server_name example.com;
location/{
proxy_pass http://67.205.128.21:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
これは働いていたし、ポート3000 を入力するための要件を削除した後、私はSSL /証明書を使用した私のアプリを実行するために必要見つけました。 私はそれがhttps://www.example.com:3000として働くようにnginxの変更を加えることができました。 しかし、今私はポート3000要件を取り除く必要があります。 私はhttp :,に使用したのと同じリバースプロキシ設定を試みましたが、うまくいかなかった。 ポート3000要件を削除するにはどうすればnginxを設定しますか。以下 は、私は私のブラウザでそれを入力すると、現在何が起こっているかである。
http://67.205.128.21 - Works
http://example.com - Redirects to https://example ; Error: Redirects too many times
http://www.example.com - Redirects to https://example ; Error: Redirects too many times
http://example.com:3000 - Works
http://www.example.com:3000 - Works
現在のnginxののconfigureation:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name example.com www.example.com;
return 301 https://$server_name$request_uri;
location ~ /.well-known {
allow all;
}
# SSL configuration
#
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
include snippets/ssl-example.com.conf;
include snippets/ssl-params.conf;
server_name example.com;
location/{
proxy_pass http://67.205.128.21:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
"502 Bad Gateway"が表示されます。私はnginxについては何も知らず、参照から指示を守ろうとしています。私たちは解決策に近づいていると思います。この502をどのように修正できますか?ありがとう、pat –
さて、それは進歩です。あなたのNode.jsアプリケーションはポート3000に対応していますか?実行中であることを確認してください。それはそうでない可能性があります。あなたのNGINXエラーログファイル(通常は '/ var/log/nginx/error.log'にあります) –
2016/11/10 12:41:30 [エラー] 7449#7449:上流:クライアント:162.200.129.120、サーバ:mysite10.com、リクエスト:「GET/HTTP/1.1」、上流:「http://67.205.128.21:3000/」、ホスト:「mysite10.com」 2016/11/10 12:41:30 [エラー] 7449#7449:*アップストリームの応答ヘッダーを読み取っている途中で上流の接続が途中で閉じられました。クライアント:162.200.129.120、サーバー:mysite10.com、リクエスト: "GET /favicon.ico HTTP/1.1 "、アップストリーム:" http://67.205.128.21:3000/favicon.ico "、ホスト:" mysite10.com "、referrer:" https://mysite10.com/ " –