0

On our network our server is reachable by

appname and appname.companyname.net

How can we get it to forward 'appname' to 'appname.companyname.net'?

appname could vary so having it work with any value there would be wonderful.

This is running on AWS elastic beanstalk. We are configuring this via EB extensions which we can pass in a line to be added to the already existing ngnix server{}

Sean256
  • 2,849
  • 4
  • 30
  • 39
  • I would have thought that a shortname could be handled the same as any unwanted subdomain. With a specific `server` block for the shortname or the FQDN. See [this answer](http://stackoverflow.com/questions/35037510/how-to-exclude-specific-subdomains-server-name-in-nginx-configuration/35039222#35039222) for guidance. – Richard Smith May 12 '17 at 18:43
  • @RichardSmith please read my last line in the question. We can't add additional server blocks as EB is putting our additions into an existing server block. We can add if() statements with return values. – Sean256 May 12 '17 at 18:52
  • Oops, I guess you'll have to use an `if` statement then. – Richard Smith May 12 '17 at 18:54
  • As a newbie to this I struggling a bit with the nginx regex, return value, etc. – Sean256 May 12 '17 at 18:55

1 Answers1

1

You may be able to detect the shortname by looking at the $http_host variable and making a redirect to the FQDN. For example:

if ($http_host = appname) {
    return 301 $scheme://appname.example.com$request_uri;
}

See this document for more, and this caution on the use of if.

Richard Smith
  • 45,711
  • 6
  • 82
  • 81