Hosting both faceook app and website on same server with apahe and tomcat
I have a facebook application hosting on a server using tomcat. I have also *apache *server on the same machine where I handle incoming requests and redirect them based on if it is coming secure port(SLL 443) or 80 (standard HTTP port). I have only one domain which is www.myfacebookapp.net.
*The problem starts when I need to host my app and website on the same server. *Normally it shouldn't be a problem however both my app and website have to support SSL (Facebook made it mandatory as it does not accept any connection which is not secure (not https) )
Below is the summary of my configuration
- I have only one domain which is www.yarimelma.net
- I have SSL certificate which supports only one domain.
- I have served my static web page content under /var/www/http/public_html/index.html
- My tomcat instance runs on 8080 and my application path is www.myfacebookapp.net/myApp
- So when I run my facebook app, it makes a POST request to URL: https://www.myfacebookapp.net/myApp
- I have configured my apache instance with virtual hosts such that,
VirtualHost1 (*: 80) ServerName www.myfacebookapp.net DocumentRoot /var/www/http/public_html/ VirtualHost1 (*: 443) #direct to tomcat** ServerName www.myfacebookapp.net DocumentRoot /var/www/http/public_html/ ProxyPreserveHost On ProxyPass / http://127.0.0.1:8080/ ProxyPassReverse / http://127.0.0.1:8080/ ServerName www.myfacebookapp.net SSLEngine on #other ssl related config
It works fine *with my facebook app and also webpage *when I access my webpage from 80 (http://www.myfacebookapp.net) **However, **I should also support my webpage support https connections. Unfortunately, I can not achieve this with this configuration. So what I would like to do,
- Access web page by https such that https://www.myfacebookapp.net
- Also, keep tomcat redirection from the secure port when it is being accessed by URL https://www.myfacebookapp.net/myApp (which facebooks invoke to render facebook app iframe)
Is it possible to achieve this without any additional domain name and SSL certificate?
I couldn't find any configuration such that,
- if the request comes from https://www.myfacebookapp.net/myApp *:443 -> then redirect to http://127.0.0.1:8080 (tomcat to server app)
- If the request comes from https://www.myfacebookapp.net -> then redirect to /var/www/html/public_html (to serve webpage)
Apache documentation says that I cant define two virtual hosts for both 443 (https) and same domain.
Basically, I want to host my facebook app and website on the same server and both should be accessible through https.
Anyone knows any solution about this?