如何在适用于NodeJS应用的AWS负载均衡器中设置nginx配置?
我一直在努力进行NGINX配置文件的多次迭代,以在AWS的EC2实例上运行NodeJS应用程序。但是我没有成功。任何帮助,将不胜感激。
我的要求:
[http
请求必须被强制为https
。
[www.example
应该重定向到example
我能够使其分别在http
和https
中工作。
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。
如何在适用于NodeJS应用的AWS负载均衡器中设置nginx配置?
我一直在努力进行NGINX配置文件的多次迭代,以在AWS的EC2实例上运行NodeJS应用程序。但是我没有成功。任何帮助,将不胜感激。
我的要求:
[http
请求必须被强制为https
。
[www.example
应该重定向到example
我能够使其分别在http
和https
中工作。
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。