zeerx7

proxy

May 24th, 2024
92
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. echo "Enter domain name (ex: example.com):"
  4. # Assign domain name to variable
  5. read domain_name
  6.  
  7. # Create a new virtual host configuration file
  8. sudo touch /etc/apache2/sites-available/$domain_name.conf
  9.  
  10. # Create the document root directory
  11. echo "Target proxy (ex: 127.0.0.1:8000):"
  12. read proxyTarget
  13.  
  14. # Add virtual host configuration to the file
  15. sudo echo "<VirtualHost *:80>
  16. ServerAdmin webmaster@$domain_name
  17. ServerName $domain_name
  18. ServerAlias www.$domain_name
  19. ProxyPass / http://$proxyTarget/
  20. ProxyPassReverse / http://$proxyTarget/
  21. </VirtualHost>" > /etc/apache2/sites-available/$domain_name.conf
  22.  
  23. # <VirtualHost *:80>
  24. # ServerAdmin [email protected]
  25. # ServerName paste.zone-xsec.com
  26. # ProxyPass / http://127.0.0.1:9999/
  27. # ProxyPassReverse / http://127.0.0.1:9999/
  28. # </VirtualHost>
  29.  
  30. # Enable the new virtual host
  31. sudo a2ensite $domain_name.conf
  32.  
  33. # Reload Apache to apply the changes
  34. sudo systemctl reload apache2
  35.  
  36. # sudo a2enmod proxy
  37. # sudo a2enmod proxy_http
  38. # sudo a2enmod proxy_balancer
  39. # sudo a2enmod lbmethod_byrequests
  40. # sudo systemctl restart apache2
Advertisement
Comments
Add Comment
Please, Sign In to add comment