Glassfish - Domain wise redirection to application - apache

I am running Glassfish Server on Linux 6 for my Oracle Apex applications running on Port 8080 and 8181(for https).
now, suppose my domain is mydomain.com,
and when I access
a.mydomain.com -> it should be redirected to application 1 (i.e a.mydomain.com:8080/apex/f?p=1)
b.mydomain.com -> it should be redirected to application 2 (i.e b.mydomain.com:8080/apex/f?p=2)
and so on...
if it is hard to figure out with Glassfish, I can also move to Apache Tomcat if required.
Any advice/idea would be greatly appreciable.

I don't know Glassfish, but you might try ProxyPass inside your virtual host config
ProxyPass / http://a.mydomain.com:8080/apex/f?p=1
Similar for the b.mydomain.com domain.
If you really want a redirect, i.e. the browser's URL changes, use Redirect instead
Redirect / http://a.mydomain.com:8080/apex/f?p=1

Related

referring to tomcat URLs via multiple aliases in an apache web server + tomcat setup

I have an apache web server that acts as a load balancer / gateway for the base url, say http://example.com
In turn, there is routing logic within the apache web server to forward the requests to individual tomcat servers eg app1, app2 via the paths http://example.com/app1, http://example.com/app2.
Here, app1 and app2 are separate tomcat instances and they are separate webapps.
Now there is a need to refer to http://example.com/app1 also as http://example.com/alias1, ie both /app1 and /alias1 must route to the tomcat server corresponding to app1, with only one app1 installed (ie alias1 is not a separate tomcat instance)
Any pointers to documentation for setting up an alias for a tomcat webapp in this fashion would be appreciated.
You can use apahce ReverseProxy technology to "route" request to different tomcats depending on the url: https://httpd.apache.org/docs/current/mod/mod_proxy.html
You can start with something like this:
ProxyPass "/foo/" "http://foo.tamcat.lan:8080/foo/"
ProxyPassReverse "/foo/" "http://foo.tomcat.lan:8080/foo/"
ProxyPass "/bar/" "http://192.168.254.30:8080/"
ProxyPassReverse "/bar/" "http://192.168.254.30:8080/"
and if it's working, you can add a rule (which can be another proxyPass, a rewriteRule with proxy flag or whatever you need/like) for the alias.
Even tho it's not an optimal solution, if you have multiple tomcat servin the same application, you can also load balance the traffic: https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html

Redirect from a URL to a other server

I have the following question that I do not know how to solve it in the most efficient way.
I have two servers, one with Apache where I have a Wordpress instance responding for port 80, and on another server I have a Wildfly with another application listening on port 8080. The Wordpress that I have configured on the Apache server, responds to the URL http://www.somedomain.com What I'm not so clear about is how to do when a request arrives at http://www.somedomain.com/yyyy and redirects me to the Wildfly server where an application is responding to the URL : 8080 / app
How could I do it in the most effective way? Using the rewrite module in the .htaccess file or using the Apache proxy module and configuring it in the Apache virtual host? How would I have to do it?
Thank you very much in advance.
You're mixing a few things that are not related to each other. First of all, a redirect is something different than a proxy. Redirecting means asking the client (browser) to look at another URL. A proxy, on the other hand, retrieves the content of the other URL itself and passes it to the client. Using a proxy, the other URL remains invisible to the client.
Second, mod_rewrite is not limited to htaccess configuration. In fact it's better to configure mod_rewrite in the virtual host configuration, just as you suggested with the proxy configuration.
The htaccess is simply for users who are not allowed to mess with the server configuration itself. Configuration in the htaccess can be limited by the admin for security purposes at the cost of slowing down the server.
That said, if you are looking to map your wildfly server paths into your main server's paths, you might want to use something like this inside your main server's virtual host block:
<Location "/yyyy">
ProxyPass "http://wildfly:8080/app"
</Location>
See http://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypass for detailed explanations.

apache - how to redirect to another server

I have the following problem:
I have my HomeServer on IP 192.168.0.1, it's an exposed host, getting every access from outside.
On this Server I have running some lxc containerts, two of them have apache2, etc on it.
Now I want to access every server via a special URL, for example:
cloud.example.com -> going to the "cloud" container on IP 192.168.0.101
torrent.example.com -> going to the "torrent" container on IP 192.168.0.103
everything else should go the HomeServer on 192.168.0.1
I thought of it like this: everything should go to 192.168.0.1, there I would have some VirtualHosts looking for the URL and forwarding the traffic to the needed server or showing the "default" page of the HomeServer (192.168.0.1)
The thing is, I've searched for quite a while but can't find the stuff I need.
Someone an idea?
Thanks in advance
Something like that maybe :
<VirtualHost *:80>
ServerName cloud.example.com:80
ProxyPass / http://192.168.0.101/
ProxyPassReverse / http://192.168.0.101/
</VirtualHost>
The "default page" being in the document root of the main configuration (not the virtual host).
You could also try using Caddy web server as a reverse proxy, it is the simplest to manage that I've come across and the config file is much simpler than Apache or NGINX.
I am now using HAProxy and it's working perfectly.
Send requests from outside to router -> router sends it to HAProxy container -> HAProxy sends it to the needed container

apache redirect to SSL configured site

I am trying to setup a gitlab repository and I am quite new to the web server side of things. My setup is the following:
I have an apache server which is running my main website on port 8080.
I have the gitlab configured with SSL and Nginx and running on port 2443.
At the moment, the gitlab site can be accessed through https://www.example.com:2443.
What I would like to do is setup a redirect through my apache server where if someone comes to http://www.example.com/gitlab or https://www.example.com/gitlab, they get redirected to ``https://www.example.com:2443` (preferably without the web browser text field changing).
Could this be done easily with Apache? Also, since the redirect is to an SSL site, any special things we need to consider?
You can try adding the redirect directive to your Apache VirtualHosts (8080 and 443).
Redirect permanent /gitlab https://www.example.com:2443

Apache - Redirect user to url via Proxy

I have an Apache webserver. Now users can access the apache front end url, which is:
http://192.168.32.32
Now, when the user visits that url, apache should automatically redirect him to a new url, but via a proxy server on a specific port: 192.169.34.34 3128
The redirect url can only be accessed via the proxy server, and apache can access the proxy server because they are on the same domain.
How do you do this in apache?
Thanks!
I am not 100% certain on what you want to do, but I think what you are after can be achieved with mod_proxy in combination with mod_rewite. I could be that you only need mod_proxy, I guess it depends on how much tuning options you want.
Maybe ProxyPassReverse is what you are after?