Currently, Cloud Foundry (CF) doesn't support mapping of external URL's (See discussion). The workaround is to use a reverse proxy. For this job, I hosted it Google App Engine (GAE) and used BS2 GAE Reverse Proxy. Credits to yufeiwu for the free reverse proxy app.
Prerequisite:
Prerequisite:
- Also, please read the Python Tutorial for the development environment and pushing your app to Google server.
Steps:
Steps:
- Download the reverse proxy library (license: LGPL) in http://code.google.com/p/bs2grproxy/
- Modify bs2grpconfig.py
- set TARGET_HOST to your cloud foundry url
e.g. TARGET_HOST = "mvergel.cloudfoundry.com" - Modify app.yaml
- set your registered application id
- Push the app and make it live
I will continue to use this approach for my website until CF have a proper DNS support.
[UPDATE] Many are encountering a problem with the session using this method. There is a patch that fixes this issue. Thank you Marius Anton for the information.
[UPDATE] Many are encountering a problem with the session using this method. There is a patch that fixes this issue. Thank you Marius Anton for the information.
Thanks for sharing this. I have used this to check DNS support but session variables are not maintaining across.. Can you give me some info on this?
ReplyDeleteI have not tested this yet. I'll get back to you if I can replicate the problem. What framework are you using? I'm using Play Framework.
Deleteyes the same play!
DeleteHello Manny. I need your help. In your described way I can map "example.cloudfoundry.com" to "appid.appspot.com". But how can I map "example.cloudfoundry.com" to "example.com". I just can't figure out how did you do "mvergel.cloudfoundry.com" to "mvergel.com" mapping?
ReplyDeletemvergel.com is mapped to appid.appspot.com, appid.appspot.com is mapped to example.cloudfoundry.com. I used Google Apps (free) to map appspot to custom domain. Hope it helps
DeleteThank you for your reply. One final clarification, please. You purchased mvergel.com domain and used Google Apps to map it to appspot, right?
ReplyDeleteTIA.
Yes, but to be exact.. I used Google Apps to purchase mvergel.com domain too, and mapped it to my appspot web application.
DeleteThis comment has been removed by the author.
DeleteI make this work, but I'm having ERRORS with the URLs... can you help Me?
DeleteSure! Could you be more specific on your problem?
Deletein all the urls appear an jsessionid... so, the files are not found
DeleteI dont find any solution for this problem... can to help me?
DeleteHi there... I tried to do the Mannys way to get my own URL to point to the cloudfoundry url... and I make it work. My problem is that ma webapp is putting the jsessionid in hte url so, all the links are broken when I enter throw the www.something.com url. can someone help me please!!!!
ReplyDeleteIts very urgent!
Can you give
Delete1. the exact URL having the problem?
2. Also indicate your CloudFoundry URL
3. The framework you are using.
Hi Manny, I have the servers down at this moment... the frameworks are spring+springSec+springMVC
DeleteI think I found the problem, is an encoding problem.... when I enter to the custom url www.some.com the Tomcat server on the cloud foundry generates the jsessionid variable on the url. Like this --> http://www.some.com/login.html;jsessionid=94B514CC3052E86CBB3492ADD0D33053
DeleteBut in the page you can see an error like this -->
HTTP Status 404 - /login.html%3Bjsessionid%3D94B514CC3052E86CBB3492ADD0D33053
type Status report
message /login.html%3Bjsessionid%3D94B514CC3052E86CBB3492ADD0D33053
description The requested resource (/login.html%3Bjsessionid%3D94B514CC3052E86CBB3492ADD0D33053) is not available.
Apache Tomcat/6.0.35
So, do you have any idea how is the ; and / changing on GAE proxy? how I change the encoding on the GAE?
I have replicated the problem in my server too. I'll try to look for a solution.
DeletePlease have a look at this patch http://code.google.com/p/bs2grproxy/issues/detail?id=13
DeleteI had the same problem. The session id cookie (jsessionid if you are using jsp) was lost between requests, which resulted in creating a new session on cloudfoundry server. The above path solved this problem.
Thank you Marius! I have updated this post to reflect your suggestion.
DeleteHi Manny,
ReplyDeleteI followed your instructions, but when I try to enter to my home pages is redirected to www.google.com
Could u please help me with that?
thanks a lot!!!
This comment has been removed by the author.
ReplyDeleteadd this to web.xml
ReplyDelete%3Csession-config%3E
%3CCtracking-mode%3E
COOKIE
%3C/tracking-mode%3E
%3C/session-config%3E
This comment has been removed by the author.
DeleteCan somebody tell me what this is meant to do? I have managed to setup the reverse proxy but am having the jsessionid issue - is this meant to fix the problem?
DeletePlease check the suggestion of Marius. I have also updated the blog entry above to link the fix relating to this issue.
Deletethis no longer works fine. my cloudfoundry app has spring+springMvc+springSecurity, and the proxy is mixing the sessions!!!
ReplyDeleteUpdated the blog entry to provide a link for the fix. Please check
DeleteI tried my own reverse proxy (with Apache and mod_proxy, hosted in an EC2 instance) to map a domain to an Grails app running at CF, but the result is NGix's page. I believe CF has blocked this workaround.
ReplyDeletemvergel.com uses this approach and it's still working. Hmm...
DeleteHi . Can I know about the pricing issue ? I mean , how did you managed the "instance hour" thing on app engine ? Does page view on this site affect on GAE pricing ? If yes , then can you share some tips on how to optimize it ?
ReplyDeleteThanks in advance .