Adding a 8080 to each URl using URl rewriting? - url-rewriting

I have a domain like www.mytest.com. Now for each subpage of that page and the domain itself I want to add :8080. Like this:
www.mytest.com/correct.php --> www.mytest.com:8080/correct.php
How can I do that?
Thanks!

You can use proxy pass reverse assuming that you activate (listen on) port 8080 in your httpd.conf file or VirtualHost file assuming you're using Apache HTTPD and have root access. If not, believe you can put this into .htaccess:
<VirtualHost *:80>
...
<Proxy *>
AddDefaultCharset Off
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://www.mytest.com:8080
ProxyPassReverse / http://www.mytest.com:8080
</VirtualHost>

Related

Oracle Apex pretty URL

i need help for a problem.
Before someone complain. I have post the same question in another forum but i didn't get any useful help there.
https://community.oracle.com/tech/developers/discussion/4497783
I have seen there are a lot of things if i search by google but i am a total newbie so i hope that someone could help me.
I have a dedicated Server with apex running. I have point a domain to my apex application, so far , so good.
Now i have the url like following www.mydomain.com/apex/workspace_name/r/application
What i want to do is, that the user don't see the part "/apex/workspace_name/r" when he is working with the application.
Is there a relative easy way to do that? Something like .htaccess?
Many thanks and regards,
Andreas
Using an Apache HTTPD web server to reverse proxy your APEX connections, you can use the ProxyPass and ProxyPassReverse directives of the mod_proxy module to alter URL paths that the user sees:
ProxyPass /r /apex/workspace_name/r
ProxyPassReverse /r /apex/workspace_name/r
See the Apache documentation for more details: https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypass
In my case, I used the mod_proxy_ajp module to communicate with the cluster of Tomcat application servers running ORDS, as follows:
#######################################################
#
# APEX Virtual Host
#
#######################################################
<VirtualHost 192.168.1.101:443>
# General setup for the virtual host
DocumentRoot "/var/www/html"
ServerName apps.mydomain.com
ServerAdmin root#localhost
ErrorLog "/etc/httpd/logs/apex.ssl_error.log"
# Redirect root URL to a default application
RedirectMatch ^/$ /ords/f?p=200
... other directives here ...
<IfModule mod_proxy_ajp.c>
ProxyRequests Off
ProxyPreserveHost On
<Proxy balancer://ords_balancer>
BalancerMember ajp://appserver1:8009 route=server1
BalancerMember ajp://appserver2:8009 route=server2
</Proxy>
# Redirect /ords to the load balancer
ProxyPass /ords balancer://ords_balancer/ords stickysession=JSESSIONID|jsessionid
ProxyPassReverse /ords balancer://ords_balancer/ords
ProxyPassReverseCookiePath /ords /
# Redirect /i to the load balancer
ProxyPass /i balancer://ords_balancer/i stickysession=JSESSIONID|jsessionid
ProxyPassReverse /i balancer://ords_balancer/i
<Proxy *>
Order deny,allow
Deny from none
Allow from localhost
</Proxy>
<Location /balancer-manager>
SetHandler balancer-manager
</Location>
</IfModule>
</VirtualHost>

Not propperly routing in reversed proxy Laravel App

I have configurated an Apache Server which uses reverse proxy to show a web app developed in laravel and mounted in another apache web server. Let's say that the domain is myapp.app
Which works properly, but when I click to a subdomain, let's say myapp.app/register the browser returns myapp.appregister/.
At the moment I've configurated my webserver as it follows:
<IfModule mod_ssl.c>
<VirtualHost *:443>
SSLEngine On
ServerName myapp.app
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location "/">
RequestHeader set X-Forwarded-Proto https
RequestHeader set X-Forwarded-Ssl on
RequestHeader set X-Url-Scheme https
</Location>
ProxyPreserveHost on
ProxyPass / http://172.31.0.234/
ProxyPassReverse / http://172.31.0.234/
Include /etc/letsencrypt/options-ssl-apache.conf
ServerAlias www.redes-erdica.tech
SSLCertificateFile /***.pem
SSLCertificateKeyFile /***.pem
</VirtualHost>
</IfModule>
<IfModule mod_ssl.c>
<VirtualHost *:80>
ServerName myapp.app
Redirect permanent / https://myapp.app/
</VirtualHost>
</IfModule>
And the config file for the inner apache server has no other configurations besides the location of the laravel Project. Some curious event that happens is that if I type manually myapp.app/register it sends me where it should be, so why the browser sends me in a wrong direct when I click in the register button?
In addition, the app in localserver works properly.
You need to modify the main configuration file located on the /etc/apache2 folder, you need to change the value of the section AllowOveride that points to the folder on which your aplication lives and change it like this:
<Directory [your_app_folder]
Options ...
AllowOverride All
Require ...
</Directory>

How to remove application path by using httpd config in weblogic plugin

I developed a JSF application that named myapp was deployed on weblogic 12c http server on managed servers managedServer1 and managedServer2 in same cluster that named mycluster . Application can be access by url http://xx.xx.xx.xx(ip for managedServer1):9080/myapp.
I tried add a apache load balancer http server in the front of weblogic cluster by configure httpd (httpd.conf) as:
<VirtualHost *:80>
ServerName www.mywebsite.com.au
ServerAlias mywebsite.com.au
<Proxy balancer://mycluster>
BalancerMember http://xx.xx.xx.xx1:9080/myapp
BalancerMember http://xx.xx.xx.xx2:9080/myapp
</Proxy>
ProxyRequests off
ProxyPreserveHost On
<Proxy *>
Require all granted
</Proxy>
ProxyPass /myapp balancer://mycluster/
ProxyPassReverse /myapp balancer://mycluster/
ProxyPass / balancer://mycluster/
ProxyPassReverse / balancer://mycluster/
<Location />
Require all granted
</Location>
</VirtualHost>
by using this configure, I can access my jsf app by URL
http://www.mywebsite.com.au
directly.
Unfortunately, As my JSF App have quite lots ajax asynch requests in my jsf pages, apache reverse proxy not handle it properly, always cause session lost. I have to find alternative way to fulfil my ajax requests.
I fellow Oracle advice to install weblogic plug in for my apache http server. After installed plug in, I re-configuring my httpd.conf by using:
<VirtualHost *:80>
ServerName www.mywebsite.com.au
<IfModule mod_weblogic.c>
WebLogicCluster xx.xx.xx.xx1:9080,xx.xx.xx.xx2:9080
MatchExpression *.xhtml
</IfModule>
<Location /myapp>
SetHandler weblogic-handler
Require all granted
</Location>
</VirtualHost>
Unfortunately. I have to access my JSF application by call URL:
http://www.mywebsite.com.au/myapp
My question is: Does there is an other way to configure my virtual host to be accessed my JSF app from root? (http://www.mywebsite.com.au) that with out application path. If it is, please advise!
After couple of days work, find a way to solve this issue, httpd.conf was update to:
<Location />
SetHandler weblogic-handler
PathTrim /myapp
PathPrepend /myapp
Require all granted
</Location>
By using PathTrim and PathPrepend to map URL. System works well now.
This issue maybe help any one else who is in the same situation.

Host 2 application under one domain Apache HTTPD

I'm trying to configure Apache HTTPD 2.4 to front two different applications being hosted on the same server.
App1 is reachable on port 8080 (Tomcat)
mysingledomain.com:8080
App2 is reachable on port 3030 (Ruby [Dashing])
mysingledomain.com:3030
What I want to do is reach them respectively as mysingledomain.com/App1 and mysingledomain.com/App2
My situation is a lot like how this question start:
Host 2 Sites in HTTPD
These are both SPA applications but I'm getting quite confused on how to set this up when I do not have a DocumentRoot to separate the configuration.
How would I setup HTTPD to front the HTTP requests in this manner?
I was able to configure the ruby application to adhere to a subpath with the following configuration, but this affects the other:
<VirtualHost *:80>
ProxyRequests On # <---- WARNING DO NOT DO THIS
ProxyVia On
ProxyPreserveHost On
RewriteEngine On
ProxyPass "/app2" "http://192.168.0.62:3030/" retry=0
ProxyPassReverse "/app2/" "http://192.168.0.62/"
RewriteRule "^/assets/(.*)" "/app2/assets/$1" [R]
RewriteRule "^/views/(.*)" "/app2/views/$1" [R]
</VirtualHost>
It should be as simple as this:
<VirtualHost *:80>
ServerName mysingledomain.com
ProxyPreserveHost On
ProxyPass /App1/ http://127.0.0.1:8080/
ProxyPassReverse /App1/ http://127.0.0.1:8080/
ProxyPass /App2/ http://127.0.0.1:3030/
ProxyPassReverse /App2/ http://127.0.0.1:3030/
</VirtualHost>

How to proxy WebSocket via Apache to Play-Framework

I'm stuck with my Apache-config and appreciate any help on this.
The config is like this:
The Apache redirects all http traffic to https
It proxies requests like https://domain.tld/app1 to http://domain.tld:9000/app1 (play apps are running at app-context /app*/...)
This works very well with the following Apache-config:
<VirtualHost *:80>
ServerName domain.tld
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Redirect permanent / https://domain.tld/
Redirect permanent / https://domain.tld/
</VirtualHost>
<VirtualHost _default_:443>
#ssl-config here
<Proxy http://localhost:9000/*>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /app1 http://domain.tld:9000/app1
ProxyPassReverse /app1 http://domain.tld:9000/app1
ProxyPassReverse /app1 http://domain.tld/app1
</VirtualHost>
The problem ist, that one play-application got a WebSocket added. Which isn't working with the above setup. So I read the stuff on the play-pages. Which led me to install mod_proxy_wstunnel. I also add the following lines to the config, but had no success with that:
ProxyPass /app1/timerWs ws://domain.tld:9000/app1/timerWs
ProxyPassReverse /app1/timerWs ws://domain.tld:9000/app1/timerWs
When I'm trying to connect to https://domain.tld/rlc/timerWs I got an 500 Internal Server Error, but there are no new, more specific errors in the apache error log.
How can I configure Apache to proxy WebSocket requests properly to my play applications?
My play-apps do not have https-adapters. All the https stuff is done by the Apache-proxy.
Play-apps are on version 2.5.
Apache is on 2.4.7.
Thanks a lot for your help.
Tobias
I have solved the issue now. What did the trick was to set-up https not only on the Apache, but also on Plays application server Jetty. To do so see this link. This leads to another ProxyPass address (notice the wss instead of ws):
ProxyPass /app1/timerWs wss://domain.tld:9000/app1/timerWs
ProxyPassReverse /app1/timerWs wss://domain.tld:9000/app1/timerWs
I also had to change the WebSocket address in my Javascript, to let the Browser know, where to find the WebSocket-Backend.
$(function() {
var WS = window['MozWebSocket'] ? MozWebSocket : WebSocket
var dateSocket = new WS("wss://domain.tld/rlc/timerWs")
var receiveEvent = function(event) {
$("#timer").html(event.data);
}
dateSocket.onmessage = receiveEvent
});
Before that I used a Play-route #routes.Application.timerWs().webSocketURL(request) to address the WebSocket.

Resources