Last active
June 25, 2018 14:47
-
-
Save johnpmitsch/a69c904d9af358834907427fa697edbe to your computer and use it in GitHub Desktop.
proxy generate virt hosts apache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
base=50000 #port | |
range="192.168.121." | |
contents = <<-EOS | |
Listen %{port} https | |
<VirtualHost *:%{port}> | |
ProxyPass / https://%{ip_address}/ | |
<Location /> | |
ProxyPassReverse https://%{ip_address}/ | |
</Location> | |
SSLEngine on | |
SSLCertificateFile /etc/pki/tls/certs/localhost.crt | |
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key | |
ProxyPreserveHost on | |
SSLVerifyClient none | |
SSLProxyEngine On | |
SSLOptions +StdEnvVars +ExportCertData +FakeBasicAuth | |
SSLProxyVerify none | |
SSLProxyCheckPeerCN off | |
SSLProxyCheckPeerName off | |
SSLProxyCheckPeerExpire off | |
</VirtualHost> | |
EOS | |
Dir.mkdir("virt_hosts") | |
255.times do |count| | |
filename = "virt_hosts/virt_host_#{count}.conf" | |
ip_address = "#{range}#{count}" | |
file_contents = contents % {:ip_address => ip_address, :port => (base+count)} | |
File.open(filename, 'w') { |file| file.write(file_contents) } | |
end |
I also had to add this line to /etc/httpd/conf/httpd.conf, replacing the existing one, to make apache use subdirs in conf.d
IncludeOptional "/etc/httpd/conf.d/**/*.conf"
This works with:
httpd 2.4.6-67.el7_4.6
mod_ssl 1:2.4.6-67.el7_4.6
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
run as script in /etc/httpd/conf.d/, then restart httpd
If your dev VM is 192.168.121.143, you will go to my-dev-box.example.com:50143
the port will be 50000 + dev box last digits of VM
192.168.121.012 would be port 50012
192.168.121.232 would be port 50232