lundi 5 janvier 2015

AWS : ELB : Route 53 : Nginx : naked domain redirect

Setup

I have two rails app instances running in Opsworks Layer. I am using Route 53 and an ELB to route traffic to my Layer.


Objective

To redirect naked domain traffic to my www domain. chicken.com -> www.chicken.com


What I tried

I Alter my nginx conf (on one instance) to solve this problem. I added the following:



server {
listen 80;
server_name chicken.com;
return 301 $http://ift.tt/1zPNaD6;
}
... rest of config here


Result

Instance is no longer hittable by its IP.


ELB marked the instance I had altered as "Out of Service" since it could no longer be reached by IP (the health check fails).


Question

How can I route naked domains to www domains yet keep my ELB health checks happy?





Aucun commentaire:

Enregistrer un commentaire