[英]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配置目录,查找nginx
, conf.d
文件夹或nginx.conf
文件。 当您找到它时, 您可以覆盖默认server
配置,或应用include
语句来扩展它 ,无论是哪种方式,就nginx而言,上面的server
指令应该允许在多个端口上进行访问。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.