Kibana 5.0 apache proxy and reverse-proxy configuration fails - apache

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...

Related

How to solve Apache Proxy Error 502 (Error Reading From Remote Server)

I never received proper instruction on using a proxy in apache, and have mainly been managing by myself so far. Could really use some help with this error.
<IfModule mod_ssl.c>
<VirtualHost *:443>
DocumentRoot ...
ServerName ...
SSLCertificateFile ...
SSLCertificateKeyFile ...
Include /etc/letsencrypt/options-ssl-apache.conf
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
<Proxy *>
Require all granted
</Proxy>
<Location /test1>
ProxyPass http://127.0.0.1:3001/
ProxyPassReverse http://127.0.0.1:3001
</Location>
<Location /test2>
ProxyPass http://127.0.0.1:3000/
ProxyPassReverse http://127.0.0.1:3000
</Location>
</VirtualHost>
</IfModule>
The issue is that I receive the above error code for /test2/ but not /test1/. Thanks to anyone who has advice.

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

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.

How can I setup apache to proxy for two different tomcats on the same server?

I have to have two different tomcats on the same server both to be targeted by different domain names. I was wondering if it is possible for apache to proxy to both. I haven't found any documentation that with explanation to this solution yet.
I have below an example virtual host of the two I have on the server which proxies for the single tomcat instance so far:
<VirtualHost *:80>
ServerName tinderbox.mycompany.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
Something like
<VirtualHost *:80>
ServerName tinderbox.mycompany.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
<VirtualHost *:80>
ServerName othername.mycompany.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:9090/
ProxyPassReverse / http://localhost:9090/
</VirtualHost>
Essentially, repeat the VirtualHost block, change the server name so the block applies to your second domain name and change the target of the ProxyPass to whatever ports the second Tomcat instance is using.

Is it possible to use ProxyPass with only one ip address

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/.

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/';