Nginxを使用して、複数のnode.jsを1つのサーバーで実行できることを理解しています.Meteorを拡張すると思います。Nginx をセットアップして Ubuntu サーバーで問題なく実行しています。リクエストに応答して、それらを私のアプリケーションにプロキシすることもできます。ただし、Nginx でトラフィックを 2 番目のアプリケーションにプロキシしようとすると、障害が発生しました。
背景:
- ポート 8001 で実行されている最初のアプリ
- ポート 8002 で実行されている 2 番目のアプリ
- ポート80でリッスンするNginx
- nginx に / のトラフィックをアプリ 1 に送信させ、/app2/ のトラフィックをアプリ 2 に送信させようとしています
- domain:8001 と domain:8002 にアクセスすると、両方のアプリにアクセスできます。
私のNginx設定:
upstream mydomain.com {
server 127.0.0.1:8001;
server 127.0.0.1:8002;
}
# the nginx server instance
server {
listen 0.0.0.0:80 default_server;
access_log /var/log/nginx/mydomain.log;
location /app2 {
rewrite /app2/(.*) /$1 break;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:8002;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:8001;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
トラフィックが /app2/ に移動したときに何が起こっているのかについての洞察をいただければ幸いです。