Using Custom Domain Names With Pivotal Web Services
search cancel

Using Custom Domain Names With Pivotal Web Services

book

Article ID: 294594

calendar_today

Updated On:

Products

Services Suite

Issue/Introduction

The following explains how to setup custom Domain Names within your PWS environment. For example, if your app name is myapp and your domain is mydomain.com, you can access your app by going to http://myapp.mydomain.com or http://www.myapp.mydomain.com rather than to myapp.cfapps.io

Environment


Resolution

You will need to do the following to point your Domain Name to your Application on PWS.
  1. Register your Domain Name with a Domain Registrar.

  2. Point your Domain name to your PWS environment.

  3. Add your Domain to the PWS environment.

  4. Add a route to the PWS environment.
     

1. Register your domain name

For example, mydomain.com with a Domain Name Registrar of your choice.

 
2. Edit DNS Records: mydomain.com

Login to your Domain Name Provider's site and edit your setting as follows.
 
 TypeHostAnswerTTLPrioCreated 
 CNAME*.mydomain.commyapp.cfapps.io300N/A2016-01-01 
 
Doing the step above will forward all HTTP/https traffic for *.mydomain.com to your site on PWS myapp.cfapps.io
 
URL Forwarding: mydomain.com
 
Note: You will get an error if you hit myapp.cfapps.io at this point. So you will need to set up a forward DNS Record so that myapp.cfapps.io gets forwarded to www.myapp.cfapps.io
 
On your Domain Name Providers site, set up a URL Redirect as follows: 
 
Forward all traffic
From: http://*.mydomain.com
To: http://www.mydomain.com

3. Add your Domain to the PWS environment

cf create-domain
$cf create-domain myorg mydomain.com 

 $cf domains

Get domains in org myorg as:
name            status   
cfapps.io       shared   
mydomain.com   owned   

4. Map a route to your application using cf map-route 

$cf map-route myapp mydomain.com -n myapp
$cf map-route myapp mydomain.com -n www
cf routes
Getting routes as [email protected] ...
space         host       domain          apps   

development   myapp   mydomain.com   myapp   

development   www        mydomain.com   myapp 
You should now be able to access your Application hosted on Pivotal Web Services using your Domain name.
 
Checking DNS has been configured correctly.
 
You can check if the routing is working correctly using the Dig command.
 

$dig mydomain.com

; <<>> DiG 9.8.3-P1 <<>> mydomain.com

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 9924

;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0



;; QUESTION SECTION:

;mydomain.com. IN A



;; ANSWER SECTION:

mydomain.com. 300 IN A 75.126.100.8



;; Query time: 2198 msec

;; SERVER: 168.159.216.74#53(168.159.216.74)

;; WHEN: Tue Nov 17 10:43:53 2015



;; MSG SIZE  rcvd: 47

$dig www.mydomain.com

; <<>> DiG 9.8.3-P1 <<>> www.mydomain.com

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 36851

;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0



;; QUESTION SECTION:

;www.mydomain.com. IN A



;; ANSWER SECTION:

www.mydomain.com. 300 IN CNAME myapp.cfapps.io.

myapp.cfapps.io. 60 IN A 54.172.222.102

myapp.cfapps.io. 60 IN A 54.88.215.24



;; Query time: 194 msec

;; SERVER: 128.221.224.144#53(128.221.224.144)

;; WHEN: Tue Nov 17 10:46:24 2015

;; MSG SIZE  rcvd: 99

$ dig myapp.mydomain.com

; <<>> DiG 9.8.3-P1 <<>> myapp.mydomain.com

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 60641

;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0



;; QUESTION SECTION:

;myapp.mydomain.com. IN A



;; ANSWER SECTION:

myapp.mydomain.com. 300 IN CNAME myapp.cfapps.io.

myapp.cfapps.io. 60 IN A 54.88.215.24

myapp.cfapps.io. 60 IN A 54.172.222.102