Apache map URL to resource - apache

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.

Related

Proxy requests to node with apache except requests containing specific path

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>

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

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