Proxy requests to node with apache except requests containing specific path - apache

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>

Related

AEM: Using Reverse Proxy - Dispatcher

Could you please let me know how can we use reverse proxy to allow non aem server to post pages to a directory on the main domain on AEM site (Eg: www.yourdomainname.com/test-one)?
I have tried adding the below syntax in the vhost file in dispatcher module of Apache server for using reverse proxy. However, this didn't work and faced a 404 on dispatcher upon server restart. The reason might be dispatcher reverse proxies to the publish instance. How can we bypass this issue to setup reverse proxy?
<VirtualHost *:80>
ServerName www.yourdomainname.com
ProxyRequests off
RemoteIPHeader X-Forwarded-For
Header set xxx-Proxy-Version "1.0"
ProxyPreserveHost On
<Location /test-one >
ProxyPass "http://xxx/test-one"
ProxyPassReverse "http://xxx/test-one"
Order allow,deny
Allow from all
</Location>
<Location /test-one/(.*) >
ProxyPass "http://xxx/test-one/(.*)"
ProxyPassReverse "http://xxx/test-one/(.*)"
Order allow,deny
Allow from all
</Location>
</VirtualHost>
Thanks

Jenkins 1.616 over glassfish 4 using apache as proxy - Unable to logout

I'm using Apache as a proxy for jenkins 1.616 on glassfish 4 and I'm unable to logout while using the proxy. But this is not the case with direct access.
Apache proxy options:
<VirtualHost *:80>
ServerName example.server
ProxyRequests Off
ProxyPreserveHost On
AllowEncodedSlashes NoDecode
ProxyPass / http://GF.SERVER:8088/ nocanon
ProxyPassReverse / http://GF.SERVER:8088/
ProxyPassReverse / http://example.server/
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>
Source: Running Jenkins behind Apache
I have also tried setting the below options for JVM:
-Dhttp.proxyHost=some.proxy.host
-Dhttp.proxyPort=1234
-Dhttps.proxyHost=some.otherorsame.host
-Dhttps.proxyPort=2345
Source: JenkinsBehindProxy
All the setup but of no use.
I have a global option setup as ExpiresDefault "access 1 month".
This was causing the issue.
I put ExpiresDefault "now" in my virtual host setting and this is resolved.

Map apache2 proxy to different ports

I am running apache 2.2 and have a problem to map two different applications (Plex and Owncloud) on port 80. What I want to do is to proxy example/plex to localhost:32400/web (which is the default setting of plex). Also I want to map example/cloud on localhost/owncloud.
What I have tried so far:
<VirtualHost *:80>
ServerName example
<Proxy *>
Order deny,allow
Allow from 192.168.1.0/24
</Proxy>
ProxyPreserveHost On
ProxyRequests Off
ProxyPass /cloud http://127.0.0.1/owncloud/
ProxyPassReverse /cloud http://127.0.0.1/owncloud/
<Location /plex/>
ProxyPass http://127.0.0.1:32400/web/
ProxyPassReverse http://127.0.0.1:32400/web/
</Location>
</VirtualHost>
That works for the cloud => owncloud proxy, but for some reason, whatever I try it doesn´t work for the Plex with port 32400.
I also tried with this instead of the Location block:
ProxyPass /plex http://127.0.0.1:32400/web/
ProxyPassReverse /plex http://127.0.0.1:32400/web/
Thanks in advance!

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.

Configuring Apache Load Balancer

I have the following code added to my httpd.conf to load balance between two Application Servers
<VirtualHost www.mydomainx.com:80>
ProxyRequests off
ProxyPreserveHost Off
ServerName www.mydomainx.com
ServerAlias mydomainx.com
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /test balancer://mycluster stickysession=JSESSIONID|jsessionid
<Proxy balancer://mycluster>
# WebHead1
BalancerMember http://www1.mydomainx.com
# WebHead2
BalancerMember http://www2.mydomainx.com
Order Deny,Allow
Deny from none
Allow from all
ProxySet lbmethod=byrequests
</Proxy>
<Location /balancer-manager>
SetHandler balancer-manager
# I recommend locking this one down to your
# your office
Order deny,allow
Allow from all
</Location>
ProxyPass /balancer-manager !
ProxyPass / balancer://mycluster/
</VirtualHost>
Whenever i enter the URL to a web browser www.mydomainx.com, it loads the home page , then if i enter a user name and password and click submit, it then reloads either (http://www1.mydomainx.com / http://www2.mydomainx.com) reloading the home page again and forcing me to re-enter the username and password, is there a way to prevent all this?
Make sure you follow the advice in section stickyness:
ProxyPass / balancer://mycluster stickysession=JSESSIONID|jsessionid scolonpathdelim=On
(not only for the /test directory)
Furthermore, for the JBoss application server, you need to supply route=web1 / route=web2 etc. in the Apache config and furthermore jvmRoute="web1" in the JBoss configuration of the <Engine name="jboss.web"... element (the location depends on the JBoss version you are using, for v4.2 it is server/default/deploy/jboss-web.deployer/server.xml)
See also this tutorial