Apache Proxy

To proxy requests in Apache

<VirtualHost *:80>
ServerName youdomain.com
ProxyRequests Off
ProxyPreserveHost On
ProxyPass "/" "http://localhost:9292/"
ProxyPassReverse "/" "http://localhost:9292/"
</VirtualHost>​

The ProxyPreserveHost directive in Apache’s configuration is used in the context of a reverse proxy setup. When this directive is set to On, it tells Apache to pass the original Host header from the client request to the proxied server

ProxyRequests Off – This directive turns off forward proxying. In forward proxying, the proxy server forwards client requests to the internet. By setting ProxyRequests Off, you are ensuring that Apache only acts as a reverse proxy, not a forward proxy.

To proxy on cpanel server, use

mkdir -p /etc/apache2/conf.d/userdata/ssl/2_4/USERNAME/DOMAIN.EXTN/
vi /etc/apache2/conf.d/userdata/ssl/2_4/USERNAME/DOMAIN.EXTN/proxy.conf

Add the following to the proxy.conf, change ports as needed

ProxyPreserveHost On
ProxyPass "/" "http://localhost:9292/"
ProxyPassReverse "/" "http://localhost:9292/"

Rebuild Apache config

/scripts/rebuildhttpdconf
service httpd restart

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *