簡體   English   中英

針對Nodejs中多個端口的ElasticBeanStalk NGinx配置

[英]ElasticBeanStalk NGinx configuration for multiple ports in Nodejs

我在ElastiCbean stalk環境中托管了我的nodejs。 它使用默認配置和默認端口。 現在我打算打開另一個端口並從Nodejs應用程序中偵聽該端口。 這是在多個端口中打開nodejs。

我已經完成了nodejs編碼部分。但我不確定nginx的更改是否使它能夠監聽多個端口。 有人可以向我解釋一下嗎?

我只為Java后端配置了nginx,但實際上你需要配置server指令以包含你想要監聽的附加端口,例如:

server {
  # listen for the extra the port the load balancer is forwarding to
  listen        88;
  access_log    /var/log/nginx/access.log main;

  client_header_timeout 60;
  client_body_timeout   60;
  keepalive_timeout     60;
  gzip                  off;
  gzip_comp_level       4;

  location / {
    # forward to the actual port the application runs on
    proxy_pass          http://127.0.0.1:8888;
    proxy_http_version  1.1;

    proxy_set_header    Connection          $connection_upgrade;
    proxy_set_header    Upgrade             $http_upgrade;
    proxy_set_header    Host                $host;
    proxy_set_header    X-Real-IP           $remote_addr;
    proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
  }
}

因此,我建議您在您的Nodejs EB服務器上使用ssh並查找nginx配置目錄,查找nginxconf.d文件夾或nginx.conf文件。 當您找到它時, 您可以覆蓋默認server配置,或應用include語句來擴展它 ,無論是哪種方式,就nginx而言,上面的server指令應該允許在多個端口上進行訪問。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM