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
Related
I need all requests on my server to be proxied to node on port 8000 except requests containing /api/ci in their path.
This is my current config, the issue with it is that it is routing everything to port 8000, including the /api/ci requests instead of allowing them to hit the backend directly. For some reason the /api/ci rule is not being applied and being proxied instead. The backend is built in PHP with the Codeigniter framework.
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location /api/ci/>
ProxyPass !
</Location>
<Location />
ProxyPass http://localhost:8000/
ProxyPassReverse http://localhost:8000/
</Location>
Do not add '/' at the end of your exception:
<Location /api/ci>
ProxyPass !
</Location>
You could also use a wildcard like:
<Location /api/ci/*>
ProxyPass !
</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.
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.
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/';
I've always used Apache + Tomcat via mod_jk. To tell Apache not to forward /recources to Tomcat, you just put this in vhosts:
SetEnvIf Request_URI "/resources/*" no-jk
How do you do the same thing with mod_proxy. If it matters, I'm using the bitnami tomcat stack and there is a tomcat.conf with:
<Location />
ProxyPass ajp://localhost:8009/
</Location>
Do I change that somehow?
#<Location />
# ProxyPass ajp://localhost:8009/
#</Location>
ProxyPass /resources !
ProxyPass / ajp://localhost:8009/