ProxyPass|ProxyPassMatch can not have a path when defined in a location - apache

I tried the answer in this problem.
How to merge multiple ProxyPass directives in Apache?
But I am getting an error when I am starting apache saying ProxyPass|ProxyPassMatch can not have a path when defined in a location.
My 000-default.conf has below code
<VirtualHost *:80>
include location1.conf
include location2.conf
</VirtualHost>
and my location1 has,
<Location /web/?_escaped_fragment_=/>
ProxyPass /phpmyadmin !
ProxyPass / http://localhost:8082/
ProxyPassReverse / http://localhost:8082/
</Location>
and my location2 has,
<Location /web/#!/>
ProxyPass /phpmyadmin !
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</Location>

Similarly as can be seen in the question you mention, there is a necessity to drop the first argument of the ProxyPass and ProxyPassReverse clauses when nested under <Location> clause.
So consider altering your config like this:
location1:
<Location /web/?_escaped_fragment_=/>
ProxyPass /phpmyadmin !
ProxyPass http://localhost:8082/ # <== Dropped '/'
ProxyPassReverse http://localhost:8082/ # <== Dropped '/'
</Location>
location2:
<Location /web/#!/>
ProxyPass /phpmyadmin !
ProxyPass http://localhost:8080/ # <== Dropped '/'
ProxyPassReverse http://localhost:8080/ # <== Dropped '/'
</Location>
This should work fine.

Related

Kibana 5.0 apache proxy and reverse-proxy configuration fails

I'm trying to set a basic reverse proxy to access my kibana instance.
Here the kibana instance (working directly through :5601 without any problem)
#server.basePath: ""
server.basePath:"/kibana"
And my apache stuff
<VirtualHost *:80>
Servername xxxx
ProxyPreserveHost On
ProxyRequests On
ProxyPass / http://localhost:5601
ProxyPassReverse / http://localhost:5601
</VirtualHost>
The problem is I get
http://xxxx/
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /app/kibana.
Reason: DNS lookup failure for: localhost:5601app
I did some test but nothing seems to work.
Second try with
ProxyPass / http://localhost:5601/app/kibana
ProxyPassReverse / http://localhost:5601/app/kibana
This time it's better but still not OK
http://xxxx
I get a blink where I can see 'kibana is loading' and right after a big red message
Kibana did not load properly. Check the server output for more
information.
OK, that was easy ...
The apache conf is (beware of the slashes)
<VirtualHost *:80>
Servername xxxx
ProxyPreserveHost On
ProxyRequests On
ProxyPass / http://localhost:5601/
ProxyPassReverse / http://localhost:5601/
</VirtualHost>
And I let all by default on Kibana (no base.path)
Try something like this
<VirtualHost *:8190>
Servername kibana
DirectoryIndex /app/kibana
ProxyPass /app/kibana http://kibana:5601/app/kibana
ProxyPassReverse /app/kibana http://kibana:5601/app/kibana
ProxyPass /app/timelion http://kibana:5601/app/timelion
ProxyPassReverse /app/timelion http://kibana:5601/app/timelion
ProxyPass /bundles http://kibana:5601/bundles
ProxyPassReverse /bundles http://kibana:5601/bundles
ProxyPass /elasticsearch http://kibana:5601/elasticsearch
ProxyPassReverse /elasticsearch http://kibana:5601/elasticsearch
ProxyPass /status http://kibana:5601/status
ProxyPassReverse /status http://kibana:/status
ProxyPass /api/status http://kibana:5601/api/status
ProxyPassReverse /api/status http://kibana:5601/api/status
ProxyPass /api/console http://kibana:5601/api/console
ProxyPassReverse /api/console http://kibana:5601/api/console
ProxyPass /api/timelion/run http://kibana:5601/api/timelion/run
ProxyPassReverse /api/timelion/run http://kibana:5601/api/timelion/run
ProxyPass /api/timelion/functions http://kibana:5601/api/timelion/functions
ProxyPassReverse /api/timelion/functions http://kibana:5601/api/timelion/functions
ProxyPass /api/ http://kibana:5601/api/
ProxyPassReverse /api/ http://kibana:5601/api/
ProxyPass /goto/ http://kibana:5601/goto/
ProxyPassReverse /goto/ http://kibana:5601/goto/
ProxyPass /shorten http://kibana:5601/shorten
ProxyPassReverse /shorten http://kibana:5601/shorten
ProxyPass /plugins/kibana/ http://kibana:5601/plugins/kibana/
ProxyPassReverse /plugins/kibana/ http://kibana:5601/plugins/kibana/
ProxyPass /plugins/timelion/ http://kibana:5601/plugins/timelion/
ProxyPassReverse /plugins/timelion/ http://kibana:5601/plugins/timelion/
ProxyPass /app/sense http://kibana:5601/app/sense
ProxyPassReverse /app/sense http://kibana:5601/app/sense
ProxyPass /ui/fonts/open_sans/ http://kibana:5601/ui/fonts/open_sans/
ProxyPassReverse /ui/fonts/open_sans/ http://kibana:5601/ui/fonts/open_sans/
ProxyPass /es_admin/ http://kibana:5601/es_admin/
ProxyPassReverse /es_admin/ http://kibana:5601/es_admin/
ErrorLog "logs/kibana-error.log"
</VirtualHost>
Kibana 4 was less than half of that :)
On Kibana 6.5.4 slightly different version of the answer by Sergiu Indrie (which I thank for the answer). To me it would not work without the plugins part.
ProxyRequests On
ProxyPass /KIB/app/kibana http://127.0.0.1:5601/app/kibana
ProxyPassReverse /KIB/app/kibana http://127.0.0.1:5601/app/kibana
ProxyPass /KIB/app/timelion http://127.0.0.1:5601/app/timelion
ProxyPassReverse /KIB/app/timelion http://127.0.0.1:5601/app/timelion
ProxyPass /KIB/bundles http://127.0.0.1:5601/bundles
ProxyPassReverse /KIB/bundles http://127.0.0.1:5601/bundles
ProxyPass /KIB/plugins http://127.0.0.1:5601/plugins
ProxyPassReverse /KIB/plugins http://127.0.0.1:5601/plugins
ProxyPass /KIB/elasticsearch http://127.0.0.1:5601/elasticsearch
ProxyPassReverse /KIB/elasticsearch http://127.0.0.1:5601/elasticsearch
ProxyPass /KIB/status http://127.0.0.1:5601/status
ProxyPassReverse /KIB/status http://127.0.0.1:5601/status
ProxyPass /KIB/api http://127.0.0.1:5601/api
ProxyPassReverse /KIB/api http://127.0.0.1:5601/api
ProxyPass /KIB/goto http://127.0.0.1:5601/goto
ProxyPassReverse /KIB/goto http://127.0.0.1:5601/goto
ProxyPass /KIB/shorten http://127.0.0.1:5601/shorten
ProxyPassReverse /KIB/shorten http://127.0.0.1:5601/shorten
<Directory /KIB/app/kibana/>
Require all granted
</Directory>
I use this more compact virtual host configuration on Apache/2.4.10:
<Location "/">
Require all granted
ProxyPass "http://127.0.0.1:5601/" keepalive=On
ProxyPassReverse "http://127.0.0.1:5601/"
#LogLevel alert trace5
</Location>
nano /etc/apache2/sites-available/kibana-vhost.conf
<VirtualHost *:80>
Servername xxxx.name.xyz
ProxyPreserveHost On
ProxyRequests On
ProxyPass / http://localhost:5601/
ProxyPassReverse /(.*) http://localhost:5601/(.*)
</VirtualHost>
Thanks,
this work for me...

Apache map URL to resource

I'm hoping someone can help me out with my configs for apache. I have all my mod_proxy config working, but I want to add to the config so I can map /fog to serve up /var/www/fog/index.php but I'm unsure how to do this as I've only ever used apache for proxy pass.
This is my mod_proxy.conf so far:
<VirtualHost *>
<Location /movies>
ProxyPass http://localhost:8082/movies
ProxyPassReverse http://localhost:8082/movies
</Location>
<Location /tv>
ProxyPass http://localhost:8081/tv
ProxyPassReverse http://localhost:8081/tv
</Location>
<Location /download>
ProxyPass http://localhost:8080/sabnzbd
ProxyPassReverse http://localhost:8080/sabnzbd
</Location>
<Location />
ProxyPass http://localhost:8083/
ProxyPassReverse http://localhost:8083/
</Location>
</VirtualHost>
I've also tried adding the following to the top of mod_proxy.conf:
Alias /fog /var/www/fog/management
But I just get a blank page when I hit /fog
OK figured it out so I'll post to help others
ProxyPass /fog !
Alias /fog /var/www/fog
Using the ! directive prevents the proxy of /fog using the ProxyPass rule and allows the Alias to be used, without this the Alias is ignored.

ProxyPass and DocumentRoot on one domain

Let's say I have the following configuration:
<VirtualHost domain.com>
# Server names, admins, logs etc...
ProxyVia On
ProxyRequests Off
<Location "/">
ProxyPass http://localhost:8080/tomcat-webapp/
ProxyPassReverse http://localhost:8080/tomcat-webapp/
Order allow,deny
Allow from all
</Location>
</VirtualHost>
Now, I want the address domain.com/forum to display content of my MyBB forum, which has its files inside the /var/www/forum directory. How to accomplish this?
Actually, I resolved this problem with the following code:
ProxyPass /forum !
ProxyPass / http://localhost:8080/tomcat-webapp/
ProxyPassReverse / http://localhost:8080/tomcat-webapp/
Alias /forum /var/www/forum
What it is recommending is using mod_rewrite to perform the ProxyPass instead of ProxyPass/ProxyPassReverse command.
Try something like:
RewriteRule ^/forum - [L]
RewriteRule ^/(.*) http://localhost:8080/tomcat-webapp/$1 [P,L]
ProxyPassReverse / http://localhost:8080/tomcat-webapp/
I use:
<VirtualHost *:80>
#other irrelevant configs here
ProxyPass /forum http://localhost:8080/myBB
ProxyPassReverse /forum http://localhost:8080/myBB
ProxyPass / http://localhost:8081/tomcat-app
ProxyPassReverse / http://localhost:8081/tomcat-app
</VirtualHost>
You don't have to say "tomcat-app" if your tomcat app is the root app.

How do I configure a Apache proxy for my Couchapp?

I want to realize a proxy through a Apache Webserver 2.2.14 on Ubuntu 10.04.1. for a Couchapp on Couchdb 1.0.1 and I'm not experienced with that. The proxy should also redirect to another couchdb-database and some other pathes in Apaches www-path. The target is, to call the Couchapp (index.html) on sub.something.de.
My Questions are:
It works, but is there a smarter way to do that? My own way looks for me like a Workaround.
A problem is, when I do a logout with couchdb-api, I get another dialog to login from Apache. After I login, I can logout ;) The problem is, that the uri, I call for logout, looks like that _:_#sub.something.de and this don't match with my Proxy-Configuration. What is the solution?
Here is my httpd.conf Configuration:
<VirtualHost *:80>
DocumentRoot "/var/www/Something"
ServerName something
ServerAlias sub.something.de
AllowEncodedSlashes On
ProxyRequests Off
ProxyPreserveHost Off
ProxyVia On
KeepAlive Off
<Proxy *>
AuthType Basic
AuthName "Something Login"
AuthUserFile /home/user/.couchdb_htpasswd
Require valid-user
Order deny,allow
Deny from all
Allow from 127.0.0.1
Satisfy Any
</Proxy>
ProxyPass /something_data http://localhost:5984/something_data/ nocanon
ProxyPass /data http://localhost:5984/something/_design/prototype/data nocanon
ProxyPass /css http://localhost:5984/something/_design/prototype/css nocanon
ProxyPass /vendor http://localhost:5984/something/_design/prototype/vendor nocanon
ProxyPass /js http://localhost:5984/something/_design/prototype/js nocanon
ProxyPass /font http://localhost:5984/something/_design/prototype/font nocanon
ProxyPass /php http://localhost/dev/something/php nocanon
ProxyPass /uploads http://localhost/dev/something/uploads nocanon
ProxyPass /_uuids http://localhost:5984/_uuids nocanon
ProxyPass /_session http://localhost:5984/_session nocanon
ProxyPass /_users http://localhost:5984/_users nocanon
ProxyPass /_users !
ProxyPass /_uuids !
ProxyPass /_session !
ProxyPass /php !
ProxyPass /uploads !
ProxyPass /font !
ProxyPass /data !
ProxyPass /css !
ProxyPass /vendor !
ProxyPass /js !
ProxyPass /something_data !
ProxyPass / http://localhost:5984/something/_design/prototype/index.html nocanon
ProxyPassReverse / http://localhost:5984/something/_design/prototype/
RequestHeader unset Authorization
ErrorLog "/home/user/logs/couchdb_error_log"
CustomLog "/home/user/logs/couchdb_access_log" common
</VirtualHost>
Thx
Set value of urlPrefix in couch.js
#vi /etc/httpd/conf/httpd.conf
ProxyPass /_db/ http://localhost:5984/
ProxyPassReverse /_db/ http://localhost:5984/
#vi /usr/share/couchdb/www/script/couch.js
CouchDB.urlPrefix = '/_db/';

Apache and tomcat in the same Virtualhost

I have a virtualhost that looks like :
<VirtualHost *:80>
ServerName www.mysite.com
SetOutputFilter DEFLATE
RedirectMatch ^/manager$ http://www.fna.fi/manager/
DocumentRoot /build/vhosts/mysite.com
ErrorLog /build/logs/site.com-error.log
CustomLog /build/logs/site.com-access.log combined
ProxyRequests Off
RewriteEngine on
ProxyPass /manager http://127.0.0.1:8060/manager/ retry=0
ProxyPassReverse /manager http://127.0.0.1:8060/manager
ProxyPass / http://127.0.0.1:8060/app/ retry=0
ProxyPassReverse / http://127.0.0.1:8060/app/
</VirtualHost>
Now I want to add a blog in /build/vhosts/mysite.com. So it will be : http://www.mysite.com/blog but when I access this site it looks like its being forwarded to Tomcat (most likely due to the "ProxyPass /...".
Is there a way to make it work for the scenario I have?
Thanks!
Currently anything will be forwarded to the tomcat:
ProxyPass / http://127.0.0.1:8060/app/ retry=0
ProxyPassReverse / http://127.0.0.1:8060/app/
You have to add a alias before your proxy directives to your config:
Alias /blog /build/vhosts/mysite.com
<Location /blog>
# make some configs for this location like...
Options FollowSymLinks
AllowOverride None
</Location>