1

I have a website mysubdomain.mydomain.com that needs to be redirected to myotherdomain.com/coming-soon

The application, which has existing users, needs to be redirected to another site on a completely different domain.

My EC2 machine is using nginx. I've tried modifying the /etc/nginx/nginx.conf file by adding

server {
  listen 443;
  listen 80;
  server_name *.mydomain.com;
  return 301 http://www.reallifeglobal.com/coming-soon;
}

I've also tried various modifications to this including changing the server_name to thinks like .mydomain.com, *, mysubdomain.mydomain.com, but none of that seems to work.

When I go to the URL, it loads a completely blank page (instead of loading the existing app), but it does not redirect to the return url.

Also, I first tried to redirect straight through the DNS provider, but it's only working for http and they're making it very complicated for me to redirect https so I'm seeing what it takes to redirect on the AWS side of things.

I'm just a petty developer and don't know too much about devOps, anything else you need to know to help let me know.

EDIT sites-enabled: Inside the sites-enabled is a .conf file for elasticbeanstalk

map $http_upgrade $connection_upgrade {
        default         "upgrade";
        ""                      "";
}

server {
        listen 80;

        location / {
                proxy_pass http://docker;
                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;
        }
}
awwester
  • 267
  • 1
  • 3
  • 14
  • Please show the output of curl -k (headers) and the access / error logs on nginx. I'd also remove the wildcard server name and specify the subdomain(s) you want to redirect, unless you need wildcard. The redirect looks generally fine. – Tim May 05 '16 at 20:26
  • `curl -k url` and `curl url` both return nothing, posting the logs in a min. Also just to note, it is returning *nothing*, it's not returning `Could not resolve host: url` or anything like that. – awwester May 05 '16 at 20:31
  • Anything inside `/etc/nginx/sites-enabled/`? (Actually this is the place to configure stuff like this, _not_ inside `nginx.conf`.) – gxx May 05 '16 at 20:33
  • @gf_ nothing inside that file. Investigating that method now, thx – awwester May 05 '16 at 20:34
  • It's a folder, hence the trailing `/`. Actually the way to go is: store your site configs in `sites-available/`, and symlink these from there into `sites-enabled/`. Have a look [at this](http://serverfault.com/a/677803/269679). – gxx May 05 '16 at 20:36
  • oh, duh. Yeah there is a .conf file for elastic beanstalk there, i posted the contents of the file – awwester May 05 '16 at 20:41

1 Answers1

1

Credit to @gf_ for helping get the answer.

I needed to edit the server block in /etc/nginx/sites-enabled/elastic-beanstalk.conf file instead of adding in another server block to /etc/nginx/nginx.conf.

I just modified the server in that file to do the redirect and all is well.

awwester
  • 267
  • 1
  • 3
  • 14