no-jk Equivalent in mod_proxy - apache

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/

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>

Apache 2.2 reverse-proxy behind Nexus 3

The apache server is configure with following items :
<VirtualHost *:80>
...
<IfModule mod_proxy.c>
ProxyRequests Off
ProxyPreserveHost On
ProxyPass /jenkins/ http://localhost:8080/ timeout=300
ProxyHTMLURLMap http://localhost:8080 /jenkins
<Location /jenkins/>
ProxyPassReverse /
ProxyHTMLEnable On
ProxyHTMLExtended On
ProxyHTMLURLMap / /jenkins/ [L]
RequestHeader unset Accept-Encoding
</Location>
ProxyPass /nexus/ http://localhost:8081/ timeout=300
ProxyHTMLURLMap http://localhost:8081 /nexus
<Location /nexus/>
ProxyPassReverse /
ProxyHTMLEnable On
ProxyHTMLExtended On
ProxyHTMLURLMap / /nexus/ [L]
RequestHeader unset Accept-Encoding
</Location>
ProxyVia On
</IfModule>
Jenkins proxy works fine.
Nexus proxy load the page but cannot load resources. The HTML page ressources are not defined with the right path, instead of myhost.domain/nexus/static/... the URLs are myhost.domain/static/.... What's going wrong in the configuration ?
The solution is to switch Nexus context path configuration to '/nexus/'. In general, it seems that the nexus context path must match the proxy context path.

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

Using Apache as proxy server + Tomcat

I am trying to show custom page when tomcat is down, in order to do that i am usign apache server. I am trying to redirect all request to tomcat (localhost:8080), except request which start with '/error', how can I do that? I have tried something like this in httpd.conf file:
ErrorDocument 503 /error/503.html
<IfModule proxy_http_module>
ProxyPass /error http://localhost/ retry=0
ProxyPassReverse /error http://localhost/
ProxyPass / http://localhost:8080/ retry=0
ProxyPassReverse / http://localhost:8080/
</IfModule>
But didn't success.
Did you even look at the httpd documentation for ProxyPass before asking your question?
You want
ProxyPass /error !
to exclude paths starting with /error