0

I am sorry if this question as already been asked somewhere else, but I have been struggling with this for days now.

I am trying to setup a CloudFoundry Virtual Machine on a private Server. The Cloud Foundry instance works fine and my test REST service deployed on the route rest.

While connected using ssh, the following test using curl works just as expected:

curl rest.10.244.0.34.xip.io

I am trying to set the apache configuration on the private server in order to expose the applications deployed on the CloudFoundry VM to the internet.

I created a A DNS entry like cloud.MY_PUBLIC_IP and *.cloud.MY_PUBLIC_IP refering both to MY_PUBLIC_IP and would like to be able to access the applications deployed on the CloudFoundry VM using one of the two following URLS:

  • application-route.cloud.MY_PUBLIC_IP
  • cloud.MY_PUBLIC_IP/application-route

Firewall is disable.

I am not sure if this is doable using apache vhost or proxy. So far, I created the following vhost configuration:

<VirtualHost *:80>
 ServerName cloud.MY_PUBLIC_NAME.ch
 ProxyPass         /  http://10.244.0.34.xip.io/
 ProxyPassReverse  /  http://10.244.0.34.xip.io/
 ProxyRequests     Off

 RewriteEngine On
 RewriteCond %{HTTP_HOST} ^cloud\.MY_PUBLIC_NAME\.ch$  [NC]
 RewriteRule ^/([^/]+)/(.*)$ http://$1.10.244.0.34.xip.io/$2  [P,L]

</VirtualHost>

cloud.MY_PUBLIC_IP does redirect me to 10.244.0.34.xip.io but I cannot access any deployed application...

Many thanks in advance for any help.

Jérémie
  • 557
  • 4
  • 15
  • I don't have a full answer here, but in general traffic to your CF installation goes like this: browser -> HTTP(S) -> LB -> HTTP -> gorouter(s) -> app. The important parts are a.) traffic comes from the user to a load balancer b.) the load balancer terminates SSL if it's needed and c.) the load balancer forwards to one of the possibly many go router instances. You should know the IP addresses of the gorouter instances because you'd set them during the CF install. In your case, if HTTPD is the load balancer you'd want to setup ProxyPass to point to your gorouter. Exact config could vary. – Daniel Mikusa Apr 02 '15 at 14:05

1 Answers1

0

You don't have to reverse proxy to the xip.io custom dns server.

Reverse proxy directly to 10.244.0.34 which is the CloudFoundry proxy default ip.

This proxy will then check the domain name from which it is accessed against the routes and redirect the request accordingly.

Your Apache configuration should look like this :

<VirtualHost *:80>
    ServerName cloud.myname.ch
    ServerAlias *.cloud.myname.ch

    ProxyPreserveHost On

    <Location />
        ProxyPass http://10.244.0.34/
        ProxyPassReverse http://10.244.0.34/
        Order allow,deny
        Allow from all
    </Location>

</VirtualHost>

Then using the CloudFoundry CLI, create the domains and the routes using these commands :

$ cf create-domain ORG DOMAIN
$ cf create-route SPACE DOMAIN [-n HOSTNAME]

The output should look like this for the domains :

$ cf domains
Getting domains in org org-name as admin...
name                 status   
10.244.0.34.xip.io   shared   
myname.ch             owned   
cloud.myname.ch       owned 

And like this for the routes :

$ cf routes
Getting routes as admin ...

host                domain            apps   
app                 cloud.myname.ch   app  

Then you should be able to access your app at http://app.cloud.myname.ch.

Maurice Qch
  • 166
  • 1
  • 4