3

I would like to redirect some folder within apache2.

My webserver uses with plesk 11.

I followed this tutorial. It says I've got to put redirection rules in this file /etc/apache2/sites-available/default. For my webserver this file doesn't even exist. I guess that's because of plesk's website management. However there is only this one file: 000-default. I did not modify it!

I also managed to locate the config file for my domain. Which is located here

/var/www/vhosts/example.org/conf/last_httpd.include

I want to solve my problem with Apache 2 "ProxyPass". Because I think that's the easiest way to solve the redirect.

As I found out, I have to add this line

ProxyPass /folder/map/ http://www.google.de

This does not work. It exits with error "403 forbidden". Please give me a hint. Thank you!

Peter
  • 1,095

3 Answers3

7

Plesk 10/11

  1. Create your individual config for apache2:

    cd /var/www/vhosts/example.org
    sudo touch conf/vhost.conf
    sudo vim
    
  2. Insert your directives there

  3. Press I and insert these lines:

    RewriteEngine On
    ProxyPass /directory/subdir/ http://localhost:8123/
    ProxyPassReverse /directory/subdir/ http://localhost:8123/
    
  4. Press Esc, followed by :,write: wq and press

  5. Tell Apache to use the config. In a terminal:

    sudo /usr/local/psa/admin/bin/httpdmng --reconfigure-all
    sudo service apache2 restart
    

Plesk 12

  1. Login as an administrator

  2. Select the subscription

  3. Open in the control panel

  4. Web server settings

  5. Additional directives for HTTP & Additional directives for HTTPS:

    RewriteEngine On
    ProxyPass /directory/subdir/ http://localhost:8123/
    ProxyPassReverse /directory/subdir/ http://localhost:8123/
    

See also

Peter
  • 1,095
1

The other answer is correct, but I have something to add:

ProxyPass /directory/subdir/ http://localhost:8123/
ProxyPassReverse /directory/subdir/ http://localhost:8123/

There is no need to add RewriteEngine On here.

Then from a terminal, run:

/usr/local/psa/admin/bin/httpdmng --reconfigure-domain <YOUR_DOMAIN>

There is no need to restart httpd.

0

This is right:

ProxyPass /directory/subdir/ http://localhost:8123/
ProxyPassReverse /directory/subdir/ http://localhost:8123/

But I had to activate the proxy_http module first, either using the checkbox in Plesk (Tools & Settings > General Settings > Apache Web Server) or in a terminal:

sudo a2enmod proxy_http
service apache2 reload

Otherwise you'll get errors like this in your log:

No protocol handler was valid for the URL /myapp. 
If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.