How do I configure a Apache proxy for my Couchapp? - apache

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

Related

How to set route to load balaced each worker in Apach with mod_proxy?

Include service_url/url.inc
<VirtualHost *:80>
ServerName serverurl
ProxyRequests Off
ProxyPreserveHost On
<Location /balancer-manager>
SetHandler balancer-manager
#Require ip 10.0.0.1 10.0.0.2
</Location>
ProxyPass /balancer-manager !
<Location /route1>
ProxyPass "http://localhost:18080"
ProxyPassReverse "http://localhost:18080"
</Location>
ProxyPass /route1 !
<Location /route2>
ProxyPass "http://localhost:28080"
ProxyPassReverse "http://localhost:28080"
</Location>
ProxyPass /route2 !
ProxyHCExpr ok234 {%{REQUEST_STATUS} =~ /^[234]/}
ProxyHCExpr gdown {%{REQUEST_STATUS} =~ /^[5]/}
ProxyHCExpr up {hc('body') =~ /UP/}
<Proxy "balancer://bal">
BalancerMember "http://localhost:18080" timeout=2 hcmethod=GET hcinterval=5 hcexpr=up hcuri=/api/healthbody
BalancerMember "http://localhost:28080" timeout=2 hcmethod=GET hcinterval=5 hcexpr=up hcuri=/api/healthbody
ProxySet failontimeout=on
</Proxy>
ProxyPass "/" "${service_url}"
ProxyPassReverse "/" "${service_url}"
</VirtualHost>
Hi gyus
Avobe is my httpd.conf
now status
http://serverurl/route1, http://serverurl/route2 can access each worker
when move into other link turn to http://serverurl/otherlink
So, I need some solution that when access through route1 or route2, apache redirect http://serverurl/route1/otherlink or http://serverurl/route2/otherlink and then server admin can access each worker
Thank you

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

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.

Apache ProxyPass Root

I have setup apache fronting my services using the following example config.
/etc/apache2/conf-enabled/services.conf
<Location /A>
ProxyPass http://localhost:8082
ProxyPassReverse http://localhost:8082
</Location>
<Location /B>
ProxyPass http://localhost:8083
ProxyPassReverse http://localhost:8083
</Location>
<Location />
ProxyPass http://localhost:8084
ProxyPassReverse http://localhost:8084
</Location>
However adding <Location /> stops all my other proxy pass's from working, I just get an error has occurred, can anyone suggest what I'm doing wrong?
Thanks,
Jack
Use LocationMatch with negative lookahead on the last one:
<LocationMatch "^/(?!(A|B)/?)">
ProxyPass .....
</LocationMatch>
This will have the last one only proxypass if it is NOT /A or /B

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>