Skip to main content

Subdomain proxy vHost template for all users

Comments

2 comments

  • techAMIGO
    HI Gamecock generally,if common unique rules needs to be affected to all virtual host you can add the rules to any of the following files /etc/apache2/conf.d/userdata/custom_rule.conf /etc/apache2/conf.d/includes/pre_virtualhost_global.conf /etc/apache2/conf.d/includes/post_virtualhost_global.conf
    but according to your requirement, each domain should have separate proxy pass where example.com will vary so above method will not work . so in order to achieve that, you can edit the following apache template files /var/cpanel/templates/apache2_4/vhost.default /var/cpanel/templates/apache2_4/ssl_vhost.default
    and add the following code at the end but just before the virtual host closing tag RewriteCond %{HTTP_HOST} !^foo.[% vhost.servername %]$ RewriteCond %{HTTP_HOST} ^foo\. RewriteCond %{HTTP:Upgrade} !websocket [nocase] ProxyPass "/" "http://127.0.0.1:8080" ProxyPassReverse "/" http://127.0.0.1:8080/
    this is just a sample and you can change the code accordingly based on the requirement after that rebuild the apache conf and restart apache, then all virtual host will be added with above apache settings automatically /scripts/rebuildhttpdconf /scripts/restartsrv_httpd
    to revert any chnages simply delete the added code and rebuild the apache again..
    0
  • cPRex Jurassic Moderator
    Thanks, @techAMIGO !!!!
    0

Please sign in to leave a comment.