Showing posts with label Use Redirect and Proxypass under one virtualhost in apache. Show all posts
Showing posts with label Use Redirect and Proxypass under one virtualhost in apache. Show all posts

Friday, December 15, 2017

Use Redirect and Proxypass under one virtualhost in apache


If you need to redirect your domain on another domain or you need to redirect http to https, you use Redirect Permanent in your virtualhost to achieve but if your application is running on different port (node, python, ruby etc) and you have resolved port using proxy pass then your redirect attribute might not be working.

To solve this issue, use redirect under proxy directive.

<VirtualHost *:80>
    ProxyPreserveHost On
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/

<Proxy *>
    Redirect permanent / https://domain.co.in
</Proxy>

</VirtualHost>

Now your port will be resolved with domain as well as you can redirect domain too.