Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- echo "Enter domain name (ex: example.com):"
- # Assign domain name to variable
- read domain_name
- # Create a new virtual host configuration file
- sudo touch /etc/apache2/sites-available/$domain_name.conf
- # Create the document root directory
- echo "Target proxy (ex: 127.0.0.1:8000):"
- read proxyTarget
- # Add virtual host configuration to the file
- sudo echo "<VirtualHost *:80>
- ServerAdmin webmaster@$domain_name
- ServerName $domain_name
- ServerAlias www.$domain_name
- ProxyPass / http://$proxyTarget/
- ProxyPassReverse / http://$proxyTarget/
- </VirtualHost>" > /etc/apache2/sites-available/$domain_name.conf
- # <VirtualHost *:80>
- # ServerAdmin [email protected]
- # ServerName paste.zone-xsec.com
- # ProxyPass / http://127.0.0.1:9999/
- # ProxyPassReverse / http://127.0.0.1:9999/
- # </VirtualHost>
- # Enable the new virtual host
- sudo a2ensite $domain_name.conf
- # Reload Apache to apply the changes
- sudo systemctl reload apache2
- # sudo a2enmod proxy
- # sudo a2enmod proxy_http
- # sudo a2enmod proxy_balancer
- # sudo a2enmod lbmethod_byrequests
- # sudo systemctl restart apache2
Advertisement