I need to use the following Rewrite rule with the proxyPass and proxyPassReverse
RewriteEngine On
RewriteRule ^(market|stock|mutual)$ stackoverflow/$1 [L]
My virtual host defination is
<VirtualHost *>
ServerName localhost
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
Where Shall I insert the rewrite rule so that when I hit the URL -- localhost/market, then it will perform an internal rewrite to localhost:8080/stackoverflow/market
Please help
Got it
<VirtualHost *>
ServerName localhost
ProxyPass / http://localhost:8080/stackoverflow/
ProxyPassReverse / http://localhost:8080/stackoverflow/
RewriteEngine On
RewriteRule ^(market|stock|mutual)$ stackoverflow/$1 [L]
</VirtualHost>
Related
This is my apache configuration. As far as I can tell, redirecting from 80 to 443 should be working, but it's not. I also tried the Redirect directive without quotes and deleting the ProxyPass & ProxyPassReverse from the 80 virtual host without avail.
What am I doing wrong?
<VirtualHost *:80>
ServerName myserver.com
ServerAlias www.myserver.com
ProxyPass / http://myserver.com:8080/
ProxyPassReverse / http://myserver.com:8080/
Redirect "/" "https://myserver.com/"
</VirtualHost>
<VirtualHost *:443>
ServerName myserver.com
ServerAlias www.myserver.com
ProxyRequests Off
RewriteEngine on
# Rewrites websocket configuration
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC,OR]
RewriteCond %{HTTP:CONNECTION} ^keep-alive,\ Upgrade$ [NC]
RewriteRule .* ws://127.0.0.1:8080%{REQUEST_URI} [P]
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
SSLEngine on
SSLCertificateFile /path/fullchain.pem
SSLCertificateKeyFile /path/privkey.pem
ProxyPass / http://myserver.com:8080/
ProxyPassReverse / http://myserver.com:8080/
<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>
Can you try this code?
<VirtualHost *:80>
ServerName myserver.com
ServerAlias www.myserver.com
Redirect Permanent / https://myserver.com/
</VirtualHost>
<VirtualHost *:443>
ServerName myserver.com
ServerAlias www.myserver.com
RewriteEngine on
SSLEngine on
ProxyRequests Off
ProxyPass / http://myserver.com:8080/
ProxyPassReverse / http://myserver.com:8080/
RewriteCond %{SERVER_NAME} =myserver.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
SSLCertificateFile /path/fullchain.pem
SSLCertificateKeyFile /path/privkey.pem
</VirtualHost>
I know this is a common problem and I know there is a simple solution, however I cannot get the solutions that I have found online to work with my situation.
I have an address as such:
https://localhost/cms
However, when a visitor goes to this address apache cannot find the resource, but if a visitor goes to:
https://localhost/cms/
it works, as expected. So, to combat this I am trying to created a mod rewrite condition, but I am having a bit of trouble. Here is my conf file so far:
<VirtualHost *:443>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.*)/cms
RewriteRule ^(.*)$ https://%{SERVER_NAME}/$1/ [L,R=301]
ProxyPreserveHost on
ProxyRequests off
ProxyPass /cms/ http://localhost:9000/cms/
ProxyPassReverse /cms/ http://localhost:9000/cms/
</VirtualHost>
Any suggestions?
So, I figured it out by using ReverseProxy, here is the updated conf file:
<VirtualHost *:443>
ProxyPreserveHost on
ProxyRequests off
ProxyPass /cms/ http://localhost:9000/cms/
ProxyPassReverse /cms/ http://localhost:9000/cms/
ProxyPass /cms http://localhost:9000/cms/
ProxyPassReverse /cms http://localhost:9000/cms/
</VirtualHost>
I would like to make a redirect with unchanged URL. I have tried the configuration
<VirtualHost *:80>
ServerName test.localhost
ProxyPreserveHost On
ProxyPass / http://www.example.com/
ProxyPassReverse / http://www.example.com/
</VirtualHost>
but it doesn't work as I get a message in the browser saying "The page isn't redirecting properly". Any clues?
Do a rewrite with the proxy flag P:
<VirtualHost *:80>
ServerName test.localhost
RewriteEngine On
RewriteRule /(.*)$ http://www.example.com/$1 [P]
</VirtualHost>
In apache virtual host I attempted to redirect /db to the exist database. This works only momentarily such that it shows the exist welcome screen but then exist redirects to the dashboard and that page is not found.
ProxyPreserveHost On
ProxyRequests Off
ProxyPass /db http:**localhost:8899
ProxyPassReverse /db http:**localhost:8899
I'd like to set things up so I can do REST queries like /db/rest
What am I doing wrong?
Thanks
You need to do some URL rewriting and cookie handling: the following example maps "/" and "myapp2". It is possible to map to /rest/db/myapp1 too.
<VirtualHost *:80>
ProxyRequests off
ServerName myserver
ProxyPass /myapp2/ http://localhost:8080/exist/apps/myapp2/
ProxyPassReverse /myapp2/ http://localhost:8080/exist/apps/myapp2/
ProxyPass / http://localhost:8080/exist/apps/myapp1/
ProxyPassReverse / http://localhost:8080/exist/apps/myapp1/
ProxyPassReverseCookieDomain localhost myserver
ProxyPassReverseCookiePath / /exist
RewriteEngine on
RewriteRule ^/(.*)$ /$1 [PT]
</VirtualHost>
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.