Is it possible to use ProxyPass with only one ip address - apache

I am looking to achieve this configuration. So I tried this but the server is allways looking for server_test and server_prod in the htdocs under Apache. What I want is to redirect the request to the Tomcat server. If I use different ports without the /server_test and /server_prod, it worked but it's not what I wanted.
<virtualhost mydomaine.com/server_test:80>
ServerName mydomaine.com
ProxyRequests Off
ProxyPass / ajp://internalIp:8008/
ProxyPassReverse / http://mydomaine.com/server_test/
ProxyPassReverseCookiePath / /
</virtualhost>
<virtualhost mydomaine.com/server_prod:80>
ServerName mydomaine.com
ProxyRequests Off
ProxyPass / ajp://internalIp:8009/
ProxyPassReverse / http://mydomaine.com/server_prod/
ProxyPassReverseCookiePath / /
</virtualhost>
Any help would be appreciated

Try this:
<virtualhost mydomaine.com:80>
ServerName mydomaine.com
ProxyRequests Off
ProxyPass /server_test ajp://internalIp:8008/
ProxyPass /server_prod ajp://internalIp:8009/
ProxyPassReverse /server_test ajp://internalIp:8008/
ProxyPassReverse /server_prod ajp://internalIp:8009/
</virtualhost>
However, you would not be able to use ProxyPassReverseCookiePath, because both Tomcat sites would set cookies with / as the path.
To make it work as I believe you want, you need to have two separate VirtualHosts. If you only have one IP address, you need to use name-based virtual hosts.
For example, add a subdomain test.mydomaine.com that has the same IP address as mydomaine.com. Then use this configuration:
NameVirtualHost mydomaine.com:80
<virtualhost mydomaine.com:80>
ServerName mydomaine.com
ProxyRequests Off
ProxyPass / ajp://internalIp:8009/
ProxyPassReverse / ajp://internalIp:8009/
</virtualhost>
<virtualhost mydomaine.com:80>
ServerName test.mydomaine.com
ProxyRequests Off
ProxyPass / ajp://internalIp:8008/
ProxyPassReverse / ajp://internalIp:8008/
</virtualhost>
You can then access your production site at http://mydomaine.com/ and your test site at http://test.mydomaine.com/.

Related

Apache2 and Graylog

i need to solve quickly this problem.
I have a apache2 running on server and a graylog installed and running and i cannot reach the localhost:9000 where the graylog is running. I try to configure virtualhost, but i can't configure correctly.
i try this config, and many others, but no one help me.
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName www.graylog.xxxxxx.com
ServerAlias example.com
ProxyPass / http://127.0.0.1:9000/
ProxyPassReverse / http://127.0.0.1:9000/
</VirtualHost>
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName www.graylog.xxxxxx.com
ServerAlias example.com
ProxyPass / http://127.0.0.1:9000/
ProxyPassReverse / http://127.0.0.1:9000/
</VirtualHost>

Apache reverse proxy match requests

My server hosts two web services: WordPress(on Port 8080) and Flask(on Port 8081). I am setting up a reverse proxy as I want any requests start with /admin goes to Flask and all others go to Wordpress.
For example:
http://aa.mcmaster.ca/admin/aa Goes to Port 8080
http://aa.mcmaster.ca/page1 Goes to Port 8081
http://aa.mcmaster.ca/page1 Goes to Port 8081
My setting is:
<VirtualHost *:80>
DocumentRoot /wordpress/wp-content
SSLProxyEngine On
ProxyPreserveHost On
ServerName aa.mcmaster.ca
ProxyRequests off
ProxyPass /admin http://aa.mcmaster.ca:8080/
ProxyPassReverse /admin http://aa.mcmaster.ca:8080/
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /wordpress/wp-content
SSLProxyEngine On
ProxyPreserveHost On
ServerName aa.mcmaster.ca
ProxyRequests off
ProxyPass /http://aa.mcmaster.ca:8081/
ProxyPassReverse / http://aa.mcmaster.ca:8081/
</VirtualHost>
It doesn't work. I am stuck on how to set up to matchs requests other than /admin. Can I get some help?
Thanks!
Use below ProxyPass in a single VirtualHost and test.
ProxyPass /admin/ http://aa.mcmaster.ca:8080/
ProxyPassReverse /admin/ http://aa.mcmaster.ca:8080/
ProxyPass / http://aa.mcmaster.ca:8081/
ProxyPassReverse / http://aa.mcmaster.ca:8081/

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

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