You don't want to go that route. The whole principle driving Cloud Foundry
is that it assigns a unique domain name to each application and for that to
work you need to do a wild card DNS assignment to the node where the router
lives.
I'm attaching below an expect script that automates the DNS assignment to a
node configured with the Cloud Foundry dev setup. It makes some assumptions
on where Cloud Foundry is installed ("/root/cloudfoundry") but should
document the complete required configuration steps for assigning an
arbitrary domain to a node. As an example, if the node has IP 1.2.3.4 and
you have made a wildcard DNS assignment of *.my.custom.domain.com to
1.2.3.4 then you use the script with:
cf_assign_domain.expect 1.2.3.4 my.custom.domain.com
and then use "vmc api.my.custom.domain.com" to login. Note that ssh into
the root account has to be configured for the script to work. Hope this
helps.
/Stefan
#!/usr/bin/expect
## This script will set a custom domain name for Cloud Foundry vcap_dev
based installation.
## It updates:
## - the configuration files in the .deployment/<deployment name>/config
directory
## - the nginx_router configuration
set timeout 600
if {[llength $argv] < 1} {
puts "Usage: hostname \[domain\]"
exit
}
set rhost [lindex $argv 0]
set domain "vcap.me"
if {[llength $argv] > 1} {
set domain [lindex $argv 1]
}
set ctrl_a_d "\01d"
spawn /usr/bin/ssh $rhost
expect "*root@"
send {ip=`ifconfig eth0 | sed -n 's/.*inet addr:\(\S*\).*/\1/p'`}; send "\r"
expect "*root@"
#send "echo \$ip\r"
#expect "*root@"
#send "screen -S cf_domain_set \r"
#expect "*root@"
## stop all services
send "/root/cloudfoundry/vcap/dev_setup/bin/vcap_dev stop\r"
expect "*root@"
send "cd cloudfoundry/.deployments/devbox\r"
expect "*root@"
send "find config -type f| xargs sed -i
's|cloud_controller_uri:.*|cloud_controller_uri: http://api.$domain|'\r"
expect "*root@"
send "find config -type f| xargs sed -i \"s|local_route:.*|local_route:
\$ip|\"\r"
expect "*root@"
send "sed -i 's|^admins:.*|admins: \[ admin@$domain \]|'
config/cloud_controller.yml\r"
expect "*root@"
send "sed -i 's|allow_external:.*|allow_external: true|'
config/cloud_controller.yml\r"
expect "*root@"
send "sed -i 's|allow_external_app_uris:.*|allow_external_app_uris: true|'
config/cloud_controller.yml\r"
expect "*root@"
send "sed -i 's|external_uri:.*|external_uri: api.$domain|'
config/cloud_controller.yml\r"
expect "*root@"
send "sed -i 's|url:.*|url: http://uaa.$domain|'
config/cloud_controller.yml\r"
expect "*root@"
send "sed -i -e '/^uaa:/,/^\w/{/^\w/!d}' -e '/^uaa:/d' config/uaa.yml\r"
expect "*root@"
## add uaa domain config to uaa.yml
send "echo uaa: >> config/uaa.yml\r"
expect "*root@"
send "echo ' uris: \[ uaa.$domain, login.$domain \]' >> config/uaa.yml\r"
expect "*root@"
send "sed -i 's|\"domain\":\"\[^\"\]*\"|\"domain\":\"$domain\"|'
config/deploy.json\r"
expect "*root@"
## fix resolver in nginx router config (use Google DNS)
send "sed -i -e '/^ *resolver.*/d' -e 's/server *{.*/&\\n resolver
8.8.8.8;/' deploy/nginx/nginx-0.8.54/conf/nginx_router.conf\r"
expect "*root@"
## restart nginx_router
send "service nginx_router restart\r"
expect "*root@"
## start all services
send "/root/cloudfoundry/vcap/dev_setup/bin/vcap_dev start\r"
expect "*root@"
send "exit \r"
On Monday, December 3, 2012 2:29:12 PM UTC+1, Oriol Collell Martin wrote:
Hello,
We have deployed a CF instance in one of our servers and I would like to
know if the Cloud Controller or Nignx can be configured so that it can be
accessed through a public IP instead of by using a domain name. For
instance, let's say that the IP is 1. 2. 3. 4, the idea is that the api
could be accessed through 1. 2. 3. 4/api or something similar, the uaa
through 1. 2. 3. 4/uaa and deployed applications through 1. 2. 3. 4/myapp.
The idea of doing this is because we want to avoid, if possible, having to
acquire a domain name, but still have the need to access the CF instance
from outside the network where it's installed.
Thanks in advance,
Oriol.