最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

如何在适用于NodeJS应用的AWS负载均衡器中设置nginx配置?

运维笔记admin17浏览0评论

如何在适用于NodeJS应用的AWS负载均衡器中设置nginx配置?

如何在适用于NodeJS应用的AWS负载均衡器中设置nginx配置?

我一直在努力进行NGINX配置文件的多次迭代,以在AWS的EC2实例上运行NodeJS应用程序。但是我没有成功。任何帮助,将不胜感激。

我的要求:

[http请求必须被强制为https

[www.example应该重定向到example

我能够使其分别在httphttps中工作。

www到非www完全不起作用。

我评论了我用来迫使http变为https的逻辑>

如果取消注释,则在LoadBalancer中会不断出现OutOfService错误。

我的NGINX配置代码:

server {

 listen       80;
 listen       443;

 server_name example;

 root  /opt/bitnami/apache2/htdocs/vdc_live;


 location /  {
            proxy_pass    http://localhost: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;
    }


  # proxy_set_header X-Forwarded-Proto $scheme;
  # if ( $http_x_forwarded_proto != 'https' )
  # {
  #    return 301 https://$host$request_uri;
  # }


}


server
{
   server_name www.example;
   return 301 $scheme://example$request_uri;
}

我一直在努力进行NGINX配置文件的多次迭代,以在AWS的EC2实例上运行NodeJS应用程序。但是我没有成功。任何帮助,将不胜感激。我的要求:http ...

回答如下:

http请求必须强制为https。

发布评论

评论列表(0)

  1. 暂无评论