Httpd.conf redirect to external url apache tomcat - apache

I have an application that makes a call to an external URL.
When I try to run it in localhost only some static HTML files which are in the localhost get loaded.
Any files located on the external URL doesn't load. It returns a 404 not found error.
I am using Apache sever, and Tomcat to run the application.
My Httpd.conf file has the following changes:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests On
ProxyVia On
ServerName localhost
ServerAlias *.localhost
ProxyPass /ab-ux-sass http://localhost:8080/ab-ux-sass
ProxyPassReverse /ab-ux-sass http://localhost:8080/ab-ux-sass
ProxyPass /ux-services https://boot.lender.com/ux-services
ProxyPassReverse /ux-services
https://boot.lender.com/ux-services
</VirtualHost>
what config changes needs to be made?

Made the following changes in the Httpd.conf file. It is working now.
<VirtualHost *:80>
ServerName dev.localhost
SSLProxyEngine on
ProxyRequests Off
<Proxy *>
Order allow,deny
Allow from All
</Proxy>
ProxyPass /ab-ux-sass http://localhost:8080/ab-ux-sass
ProxyPassReverse /ab-ux-sass http://localhost:8080/ab-ux-sass
ProxyPass /ux-services https://boot.lender.com/ux-services
ProxyPassReverse /ux-services
https://boot.lender.com/ux-services
</VirtualHost>

Related

Redirect subdomain to subdomain+folder

I've linked a subdomain to my Tomcat app, but I donĀ“t want to put the name of the folder to access. I've done this using Apache as a proxy.
<VirtualHost *:80>
ServerName domain.example.com.pe
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /SSHR http://192.168.10.52:8081/SSHR
ProxyPassReverse /SSHR http://192.168.10.52:8081/SSHR
</VirtualHost>
I've tried with this lines:
ProxyPass / http://192.168.10.52:8081/SSHR/
ProxyPassReverse / http://192.168.10.52:8081/SSHR/
It works, but I've some problems with the Tomcat application. So, what I need is something to redirect from example.domain.com.pe to example.domain.com.pe/SSHR.

Start two Play! application on same name server

I'm trying to run two different web application on the same server, with the same domain name, like :
www.example.com/app1
www.example.com/app2
The applications are developed using Play! framework, and I'm using Apache as a reverse proxy. I tried to follow the online guide, set up the virtual host and etc..., but nothing seem to works, only the first app is reacheble, while the second isn't.
This is as far as I got untill now with my apache config file :
<VirtualHost *:80>
ProxyPreserveHost On
DocumentRoot "/home/App1/"
ServerName http://www.example.com/app1
ProxyPass /excluded !
ProxyPass / http://127.0.0.1:9000/app1
ProxyPassReverse / http://127.0.0.1:9000/app1
LogLevel debug
</VirtualHost>
<VirtualHost *:80>
ProxyPreserveHost On
DocumentRoot "/home/App2"
ServerName http://www.example.com/app2
ProxyPass /excluded !
ProxyPass / http://127.0.0.1:8000/app2
ProxyPassReverse / http://127.0.0.1:8000/app2
LogLevel debug
</VirtualHost>
Route, code and everithing are correct, it's just that I can't get these apps work together.
(I also tried to implement the load balacer showed on the online guide, but it didn't work)
Thanks.
I don't think you can have two virtual hosts with the same host name - that doesn't make sense, virtual hosts are for serving different host names, for example, for serving foo.example.com and bar.example.com.
I think what you want is something roughly like this:
<VirtualHost *:80>
ProxyPreserveHost On
ServerName www.example.com
DocumentRoot /some/path/to/something
ProxyPass /excluded !
ProxyPass /app1 http://127.0.0.1:9000/app1
ProxyPassReverse /app1 http://127.0.0.1:9000/app1
ProxyPass /app2 http://127.0.0.1:8000/app2
ProxyPassReverse /app2 http://127.0.0.1:8000/app2
LogLevel debug
</VirtualHost>
James' answer is correct, you just need to fit it to your needs, I shoot that works out of the box:
<VirtualHost *:80>
ProxyPreserveHost On
ServerName www.example.com
ProxyPass /app1 http://127.0.0.1:9000/
ProxyPassReverse /app1 http://127.0.0.1:9000/
ProxyPass /app2 http://127.0.0.1:8000/
ProxyPassReverse /app2 http://127.0.0.1:8000/
</VirtualHost>
Note, that you will need to prefix EVERY route in your apps to reflect the folder path with app1 and app2, like:
foo site
bar site

502 Proxy Error - MeteorJS on Apache

I am new to Meteor, and I have an existing server that is hosting a few websites (CentOS). I use Apache to serve the sites and wanted to have a Meteor app running on a subdomain.
Here is what I have for the Meteor site in httpd.conf:
<VirtualHost *:80>
ServerName www.subdomain.domain.net
ServerAlias subdomain.domain.net
DocumentRoot /var/www/my_meteor_directory/testapp
ProxyRequests Off
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://127.0.0.1:3000
ProxyPassReverse / http://127.0.0.1:3000
</VirtualHost>
I also have this at the bottom of my httpd.conf file:
<Proxy *>
Allow from 127.0.0.1
</Proxy>
ProxyPreserveHost On
ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ ajp://localhost:3000/$1$2
I set the app to run on port 3000 and when I try to hit it in the browser (subdomain.domain.net) I get these 502 errors:
Any suggestions?
Try this...
<VirtualHost *:80>
ServerName meteorapp.example.com
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass http://localhost:8080/
ProxyPassReverse http://localhost:8080/
</Location>
</VirtualHost>
then reload the server

How to forward only *.jsp or *.do requests to Tomcat using mod_proxy?

I am using mod_proxy module to forward all requests for one of my domain to be served by Tomcat. However I want to forward only requests ending *.jsp or *.do or *.something to Tomcat and rest (e.g. *.html, *.php, *.png) to be served by Apache server. How to achieve that using mod_proxy?
Following is sample httpd.conf config that I am using currently:
<VirtualHost *:80>
DocumentRoot /usr/share/tomcat6/webapps/mywebapp
ServerName example.com
ServerAlias www.example.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/
</VirtualHost>
I know that you had found the answer but I write this answer for others that maybe need it:
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
#ProxyPass / ajp://localhost:8009/
ProxyPassMatch ^/(.*\.do)$ ajp://localhost:8009/$1
ProxyPassMatch ^/(.*\.jsp)$ ajp://localhost:8009/$1

Issues Setting up a reverse proxy in Apache

My roommate and I each have a separate webserver we are trying to set up. We are trying to use mod_proxy so that his server will forward requests to my machine (we have two seperate machines behind one router) based on the server name. I've given the basics of what we have in our apache config currently but we are getting a 403 Forbidden error when trying to access the second domain (the first, www domain, works fine).
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www
ServerName www.<domain1>.com
</VirtualHost>
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://<IP addr of other box>:80
ProxyPassReverse / http://<IP addr of other box>:80
ServerName <dummydomain>.gotdns.com
</VirtualHost>
Your mods-enabled/proxy.conf might be blocking any proxy requests (it's deny all by default). It should include the following instead:
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
EDIT: Also make sure that the mod_proxy submodules are sym linked into mods-enabled (in this case, the http sub module which is mods-available/proxy_http.load)
Just put both routes:
<VirtualHost *:80>
DocumentRoot "/app/"
ProxyPreserveHost On
ProxyRequests Off
ServerName app.yourdomain.com
ProxyPass /app http://yourIP:yourPort/app/
ProxyPassReverse /app http://yourIP:yourPort/app/
ProxyPass / http://yourIP:yourPort/app/
ProxyPassReverse / http://yourIP:yourPort/app/
</VirtualHost>
<Location "/app/" >
ProxyPass "http://yourIP:yourPort/app/"
ProxyPassReverse "http://yourIP:yourPort/app/"
ProxyPassReverseCookiePath "/app/" "/app/"
ProxyHTMLEnable Off
ProxyHTMLExtended On
ProxyHTMLURLMap "/app/" "/app/"
Order allow,deny
Allow from all
</Location>
This worked form me