Apache - Reverse proxy

Apache - Reverse proxy - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the Apache - Reverse proxy error on your web browser. Problem :


I am using Apache 2 and using the below virtual host definition in httpd.conf file



<VirtualHost *>
ServerName localhost
ProxyPass / http://localhost:8080/stackoverflow/
ProxyPassReverse / http://localhost:8080/stackoverflow/
RewriteEngine On
RewriteRule ^(market|stock|mutual)$ stackoverflow/$1 [L]
</VirtualHost>


Here, when I type



localhost/market


then Apache internally rewrite the URL and show me the contents of



localhost:8080/stackoverflow/market


Now my problem is: When I click on any of the link of that site having following URL



localhost:8080/stackoverflow/market/abc


Then, My address bar will show the above URL



I want my Apache server to redirect me to



localhost/market/abc


means User will be shown the above URL, but the contents will come from



localhost:8080/stackoverflow/market/abc


I was thinking if I need to set reverse proxy for this. Please help me on this.


Solution :

This is what a proper reverse proxy should look like:



<VirtualHost *:80>
ServerName sub.domain.org
ProxyRequests Off
ProxyPreserveHost On
ProxyVia full
ProxyPass / http://10.160.1.234:80/
ProxyPassReverse / http://10.160.1.234:80/
ErrorLog /var/log/apache2/error_name.log
LogLevel warn
CustomLog /var/log/apache2/access_name.log combined
</VirtualHost>


But it is REALLY unclear what you are doing. Do you WANT it to rewrite to port 8080? Are you just trying to rewrite the URL (remove one subdirectory)? If so, then you can stick with standard rewrite rules rather than a reverse proxy.


We hope that this article has helped you resolve the redirects, apache2, httpd.conf error in your web browsers. Enjoy browsing the internet uninterrupted!

Comments

Popular posts from this blog

How to redirect to any domain [duplicate]

"302 found" for index page bad for SEO?

Create redirect from url like www.example.us/?p=100&option=