apache ignore htaccess and reach tomcat - apache

I've have a java application running on tomcat and i'm using the apache mod_proxy module to pass the files to tomcat, however tomcat seems to be ignore the .htaccess files, here my vhost.conf. How can I instruct apache to read the .htaccess
< Proxy *>
Order deny,allow
Allow from all
< /Proxy>
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
my htaccess got one rule as
RewriteRule ^/login(.*)$ /system/customer/portal/1$1 [R]
my apache ignore it and reach tomcat right away ..
i was trying to use
ProxyPass /login !
but no success , any tips ?

You can use ProxyPassMatch for this with regex for excluding these locations:
ProxyPassMatch ^/(login|system/customer/portal/) !

Related

How to put Qbittorrent webui port behind a https Apache2 server?

So basically, i have a apache2 server with https where i run some application
I am tring to using mod_proxy to proxy all traffic to url example.com/qb to [::1]:qb-webui-port.
So in /etc/apache2/mods-enabled/proxy.conf, i wrote:
ProxyRequests Off
<proxy *>
AddDefaultCharset off
Order Allow,Deny
Allow from all
</proxy>
ProxyPass /transmission http://[::1]:9091/transmission
ProxyPassReverse /transmission http://[::1]:9091/transmission
ProxyVia On
ProxyPass /qb http://[::1]:8112
ProxyPassReverse /qb http://[::1]:8112
The above is my similiar configuration for Transmission, i intended to do the same trick to Qbittorrent.
But it only returned plain html from example.com/qb.
In the firefox console i noticed that there were some request towards example.com/css, example.com/script etc.
This make me confused.
Can anyone provide some insights on this one?
Thx.
You missed the trailing slash on your addresses.
Here's my config file. I added a RewriteRule in case I enter the URL without the trailing slash. With these configs I haven't needed to modify anything else to get qb reverse proxy working.
I use the "/torrent/ subdir to access my qbittorrent webUI and it's listening on the 8080 port, so you should modify this in order to get your installation fully functional.
# Para qbittorrent
RewriteEngine on
RewriteRule ^/torrent$ "/torrent/$1" [R]
ProxyPass /torrent/ http://127.0.0.1:8080/
ProxyPassReverse /torrent/ http://127.0.0.1:8080/

Configure Apache with multiple ProxyPass

i am trying to configure my apache server as proxy to serve two internal services , one listening on 8080 and should receive traffic on specific URL and the other listening on 8077 and should receive all other http traffic
I deployed and configured apache on the same server where these two services running and it is listening to 443 along with all SSL configuration and it is working fine
also I enabled the proxy_module, proxy_http_module and proxy_http2_module
What I want to achieve
if the requested URL is /webhook1 --> pass it to EP1 http://localhost:8080 and
any other requested URL should be passed to EP2 http://localhost:8077
My Current Configuration towards the first service
ProxyPass /webhook1 http://localhost:8080
ProxyPassReverse /webhook1 http://localhost:8080
Now I want to define another proxy pass to be something like
ProxyPass / http://localhost:8077
ProxyPassReverse / http://localhost:8077
putting both configuration together is not working , appreciate your help in how to configure apache to achieve my requirement
Thank you in advance
Put the ProxyPass rules in the correct order as required
if you want to evaluate /webhook1 rule and send it to 8080, else send the traffic to 8077 the rules should be on the following order
ProxyPass /webhook1 http://localhost:8080
ProxyPassReverse /webhook1 http://localhost:8080
ProxyPass / http://localhost:8077
ProxyPassReverse / http://localhost:8077
You may write ssl.conf file under /etc/apache2/sites-enabled/ as follows:-
RewriteEngine on
ProxyPass /webhook1 http://127.0.0.1:8080/
ProxyPassReverse /webhook1 http://127.0.0.1:8080/
RewriteRule ^/$ /webhook1/ [R,L]
RewriteEngine on
ProxyPass / http://127.0.0.1:8087/
ProxyPassReverse / http://127.0.0.1:8087/
RewriteRule ^/$ /EP2/ [R,L]
It will automatically redirects to HTTPS if ssl certificate is configured in apache2.

Apache forward proxy by url parameter

I want redirect any access whose URL parameter is "deep" to local server, and redirect other access to other server.
Forward a request like the following:
① url parameter starting with deep
http*://hostname/bdd?deep=1
→
http*://127.0.0.1:8080/bdd
② other url
→
http*://10.137.213.101:8080/bdd
I am setting my apache conf as the following, but it still does not work.
RewriteEngine On
RewriteCond %{QUERY_STRING} ^deep
RewriteRule "^/bdd(.*)$" /dataviewlinks/ [L]
ProxyPass /dataviewlinks http*://127.0.0.1:8080/bdd
ProxyPassReverse /dataviewlinks http*://127.0.0.1:8080/bdd
ProxyPass /bdd http*://10.137.213.101:8080/bdd
ProxyPassReverse /bdd http*://10.137.213.101:8080/bdd
What could be the solution?
I have done it like this in the past to redirect any network access on port 8080 to another directory.
<VirtualHost *:8080>
ServerName 127.0.0.1
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyRequests On
ProxyPreserveHost On
ProxyPass "/" "http://10.137.213.101:8080/bdd"
ProxyPassReverse "/" "http://10.137.213.101:8080/bdd"
</VirtualHost>
Maybe this would work for you as well.
Also make sure you have enabled proxy mod sudo a2enmod proxy and restart apache

How to exclude UserDir paths from ProxyPass

I want to configure apache UserDir cooperating with ProxyPass, that is, want all requests but starting with /~ passed to proxy.
Firstly I have ProxyPass settings for a Rails application as bellow:
ProxyPass / http://localhost:3001/
ProxyPassReverse / http://localhost:3001/
and, now I want to add public_html UserDir setting to this.
In other words, I want the requests to http://example.com/hoge/fuga goes to rails app, but those to http://example.com/~userrefer to refer to /home/user1/public_html directory.
How can I do this?
I've solved the problem by adding the line bellow to the apache config;
ProxyPassMatch ^/~ !
Does the below work?
ProxyPass /~ !
ProxyPass / http://localhost:3001/
ProxyPassReverse / http://localhost:3001/
! will tell mod_proxy not to forward requests beginning /~

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