Glassfish HTTPS redirect behind SSL offloader and Apache - apache

I have this configuration:
HTTPS load balancer / SSL offloader on port 443
Apache httpd on port 80 (different IP), using ProxyPass, ProxyPassReverse to forward to...
multiple Glassfish domains listening on different ports
Problem: Neither Glassfish nor Apache is aware that the request is HTTPS. Redirects to URLs like "/index.jsp" are being rewritten in Glassfish as http://internal_ip/index.jsp, then ProxyPassReverse rewrites to http://public_ip/index.jsp. Problem is, I need that URL to be http*s*://public_ip/...
How do I fix that - is there some Glassfish configuration I can change, or Apache httpd.conf?

I see two solutions to that:
1) use your loadbalancer to manipulate apaches response (iRule in F5, flex for A10 loadbalancers etc.)
2) set up something on the loadbalancer to send another redirect to requests coming in via HTTP to use HTTPS

Related

Serve http server behind an Apache https Proxy

It seems that it is possible to get Apache server to Proxy and Manage SSL handshake on https requests and service them as 'http' thru another server behind it.
I have configured an apache server for ProxyPass using following configuration
SSLProxyEngine On
ProxyPass / http://localhost:8081/
ProxyPassReverse / http://localhost:8081/
I am able to get all all traffic to the apache server that is listening to port 8080 direct and serve by the localhost:8081 server so
http://localhost:8080/hi is being correctly served by http://localhost:8081/hi
However the following does not work :
http**s**://localhost:8080/hi to be served by http://localhost:8081/hi
Apache is trying to pass the https:// traffic to the 8081 server, without managing the SSL handshake.
Your Apache listener on port 8080 is an http listener, not an https listener. You can't handle both types of traffic on the same port. If you want to handle SSL traffic, you'll need to set up a new context on another port with SSLEngine On and all the other normal SSL configuration (certificate, key, etc).
This question has one version of this configuration.
Also this post.

define subdomain apache's vhost with lighttpd

Apache is runnig my server with port 80 and lighttpd with 81.
I defined vhost abc.com in apache.
I want to define track.abc.com and all request goes to lighttpd. Is is possible to define track subdomain for abc.com in lighttpd?
It is possible but rather than ports you need to have 2 separate IP addresses if you want to make regular request http://www.domainname.com in your browser. Otherwise you will be forced to call http://www.domainname.com if you intend to use the same IP address for both Apache and Lighttpd server.
You need to declare listening port in both Apache config and Lighttpd otherwise they both would try to bind IP address and port 80 which will result in error and only first server would start up.
I research and answer is Apache's ProxyPass option. First I configured my subdomain on Apache's vhost. and I added my subdomain's chost config file
ProxyPass / http://my_host_name:81/
Now, all my subdomains request goes to lighttp.

Doing a proxy pass server on apache to tomcat+liferay

I have three sites hosted on liferay, and they use only one portal instance, therefore only one tomcat host.
I configured the virtual host properties on liferay, so when I type www.domain1.com, it goes to the right site.
However, when I type domain1.com, without the www prefix, it goes to the default liferay site.
One solution that I got was to do a proxy and rewrite server with apache 2, with mod_proxy_http and mod_rewrite modules.
The sites like domain1.com are rewritten to www.domain1.com, and I do a proxy pass like this:
ProxyPass / http://localhost:8085
ProxyPassReverse / http://localhost:8085
The tomcat server listens to the 8085 port, and apache listens to 8080.
But when the proxy pass goes on, I get a 403 - forbidden status.
I don't have a site hosted on apache, and I think that's why I got this status.
But I don't want to have any sites on apache, because the sites are on tomcat.
Is there a way to do this proxy setup without hosting a site on apache? Or maybe hosting a
"dummy" site, just to get the proxypass to work.
Specs:
Liferay 6.1
, Tomcat 7.0.27
, Apache 2.x
, Ubuntu Server 12.04
Best Regards!
Guilherme
try it without "/"
ProxyPass http://localhost:8085
ProxyPassReverse http://localhost:8085
or, maybe, you can do it with tomcat configuration: http://tomcat.apache.org/tomcat-6.0-doc/config/host.html#Host_Name_Aliases

How to use Apache as a proxy for JBOSS AS?

I have Apache running and serving PHP but I will also like to run JBOSS for my other web app. JBOSS is running on port 8080 while Apache is running on port 80. If there is a request for URL example.com, I want Apache to handle it because it is PHP backend but for URL example2.com, I want Apache to forward the request to port 8080 to be handled by JBOSS AS.
I appreciate any help in configuring Apache in the way I described it.
You need to use Apache proxy module: http://httpd.apache.org/docs/1.3/mod/mod_proxy.html
Your configuration of proxy will look similar to:
ProxyRequests Off
ProxyPass /foo http://foo.example.com:8080/foo

How can I set up a reverse proxy with mod_proxy without redirecting?

How can I set up a reverse proxy with mod_proxy without redirecting to another server or IP? This will be a virtual host environment. The reason I want to do this is so that mod_proxy handles the communication with the client's browser thereby freeing up web server processes to serve the next request instead of feeding the client's browser. This is especially important when using language modules such as mod_php with MPM Prefork. The flow that I'm trying to achieve is:
1. The traffic resolves to www.mydomain.com on port 80.
2. The proxy sends the request the web server.
3. The web server sends the answer back to the proxy and disconnects from the proxy.
4. The proxy feeds the client browser.
Once that is working I want to add nginx at the same IP address but for port 81 and proxy image requests to nginx on the same server. I do not want nginx handling the proxy nor do I want FCGI anything. I want my standard Apache mod_rewrite and .htaccess to work.
Thanks Tons!
Simply redirect to the localhost on a different port? Host your application on port 8080, and use mod_proxy to forward the requests:
ProxyPass /foo http://localhost:8080/foo
ProxyPassReverse /foo http://localhost:8080/foo
This may be helpful if you have application servers that are handling requests and you want multiple instances combined on a single machine. You can use one port per application server.
I don't know if it really would be faster than just using mod_php directly. Proxying requests also adds overhead.
Make sure you also use load these 2 modules
LoadModule proxy_module bin/mod_proxy.so
LoadModule proxy_http_module bin/mod_proxy_http.so
ProxyPass /TeamCity http://localhost/TeamCity
ProxyPassReverse /TeamCity http://localhost/TeamCity