node.js - Adding www to domain in elasticbeanstalk ngnix -


i have nodejs application running on elasticbeanstalk. want redirect request basedomain.com www.basedomain.com (excluding subdomain) , add https.

i have updated .config file in .ebextension folder redirect https following config file:

files:   "/tmp/45_nginx_https_rw.sh":     owner: root     group: root     mode: "000644"     content: |       #! /bin/bash        configured=`grep -c "return 301 https" /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf`        if [ $configured = 0 ]                   sed -i '/listen 8080;/a \    if ($http_x_forwarded_proto = "http") { return 301 https://$host$request_uri; }\n' /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf           logger -t nginx_rw "https rewrite rules added"           exit 0         else           logger -t nginx_rw "https rewrite rules set"           exit 0       fi  container_commands:   00_appdeploy_rewrite_hook:     command: cp -v /tmp/45_nginx_https_rw.sh /opt/elasticbeanstalk/hooks/appdeploy/enact   01_configdeploy_rewrite_hook:     command: cp -v /tmp/45_nginx_https_rw.sh /opt/elasticbeanstalk/hooks/configdeploy/enact   02_rewrite_hook_perms:     command: chmod 755 /opt/elasticbeanstalk/hooks/appdeploy/enact/45_nginx_https_rw.sh /opt/elasticbeanstalk/hooks/configdeploy/enact/45_nginx_https_rw.sh   03_rewrite_hook_ownership:     command: chown root:users /opt/elasticbeanstalk/hooks/appdeploy/enact/45_nginx_https_rw.sh /opt/elasticbeanstalk/hooks/configdeploy/enact/45_nginx_https_rw.sh 

can in adding www well.

this better done dns redirection rather nginx. each dns provider has naked domain redirection solution can use move traffic naked domain www.
example, in route 53 alias record. open route 53 hosted zone basedomain.com , create new record set. leave name blank. select a` type. set alias yes , select basedomain.com s3 website endpoints section of alias target dropdown. domain basedomain.com redirects www.basedomain.com


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -