I'm trying to redirect permanently a couple of alias domains of an application in OpenShift to a main one for SEO purposes. The application is running a working instance of Openshift Nginx Cartridge.
I currently have:
server {
listen <%= ENV['OPENSHIFT_NGINX_IP'] %>:<%= ENV['OPENSHIFT_NGINX_PORT'] %>;
root <%= ENV['OPENSHIFT_REPO_DIR'] %>/public;
location / {
index index.html index.htm;
}
server_name appname-domain.rhcloud.com;
}
server {
listen <%= ENV['OPENSHIFT_NGINX_IP'] %>:<%= ENV['OPENSHIFT_NGINX_PORT'] %>;
root <%= ENV['OPENSHIFT_REPO_DIR'] %>/public;
location / {
index index.html index.htm;
}
server_name main-alias.domain.com;
}
server {
listen <%= ENV['OPENSHIFT_NGINX_IP'] %>:<%= ENV['OPENSHIFT_NGINX_PORT'] %>;
server_name _;
return 301 $scheme://main-alias.domain.com$request_uri;
}
The returned HTTP headers are:
GET / HTTP/1.1
User-Agent: curl/7.35.0
Host: another-alias.domain.com
Accept: */*
HTTP/1.1 301 Moved Permanently
Date: Thu, 17 Nov 2016 00:43:18 GMT
* Server nginx is not blacklisted
Server: nginx
Content-Type: text/html
Content-Length: 178
Location: http://another-alias.domain.com/
As you can see, the Location header is not pointing to the correct URL.