<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" ><channel><title>JackKozik.com &#187; VirtualHost</title> <atom:link href="http://jackkozik.com/tag/virtualhost/feed/" rel="self" type="application/rss+xml" /><link>http://jackkozik.com</link> <description>Web Programming, Home Networking and Personal Travel</description> <lastBuildDate>Mon, 04 Sep 2023 14:26:56 +0000</lastBuildDate> <language>en-US</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.9.2</generator> <item><title>Setting up Virtual Servers in Openstack environment</title><link>http://jackkozik.com/setting-virtual-servers-openstack-environment/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=setting-virtual-servers-openstack-environment</link> <comments>http://jackkozik.com/setting-virtual-servers-openstack-environment/#comments</comments> <pubDate>Tue, 27 Jan 2015 04:16:03 +0000</pubDate> <dc:creator><![CDATA[Jack Kozik]]></dc:creator> <category><![CDATA[Web Programming]]></category> <category><![CDATA[Openstack]]></category> <category><![CDATA[ProxyPass]]></category> <category><![CDATA[VirtualHost]]></category><guid isPermaLink="false">http://jackkozik.com/?p=4961</guid> <description><![CDATA[<p>Background on Setting up Virtual Servers in Openstack environment: Once I got my Openstack environment setup, and I was able to create a couple of instances, I had to figure out the easiest way of managing IP Addresses and sub-domain names for web access to each of my instances. I needed web access to my [&#8230;]</p><p>The post <a rel="nofollow" href="http://jackkozik.com/setting-virtual-servers-openstack-environment/">Setting up Virtual Servers in Openstack environment</a> appeared first on <a rel="nofollow" href="http://jackkozik.com">JackKozik.com</a>.</p> ]]></description> <content:encoded><![CDATA[<p>Background on Setting up Virtual Servers in Openstack environment: Once I got my Openstack environment setup, and I was able to create a couple of instances, I had to figure out the easiest way of managing IP Addresses and sub-domain names for web access to each of my instances.</p><p>I needed web access to my openstack host. I needed web access to each of my instances, which are running virtually on the same host. Further, since I am running all of this on one server in my home network, I need to somehow map all of this to one external IP address.</p><p>This is nothing too new to me. I have lots of vintages of Linux servers in my basement, and I sort of know the ropes around setting up NAT-ing, Virtual Servers, and proxies. My question was: what&#8217;s the best practice? What would be the easiest?</p><p>I couldn&#8217;t find anything directly on this (let me know if you have a reference). So here&#8217;s what I decided to do.</p><h3>Enable Openstack Dashboard Network Access</h3><p>By default, the Openstack Horizon Django configuration strictly controls who can get access. It&#8217;s roughly localhost only. For testing purposes, I went into the settings file and removed all restrictions:</p><pre>$ cd /etc/openstack-dashboard
$ vi local_settings
...
#ALLOWED_HOSTS = ['horizon.example.com', ]
ALLOWED_HOSTS = ['*']
ZZ
$ systemctl restart httpd.service</pre><p>I tried making a restrictive list, but it kept getting in my way. When done setting up, I will lock this up.</p><p>I then verified from a different PC in the same subnet that http://192.168.100.154/dashboard works.</p><h3>Map Openstack Host to External IP Address</h3><p>Using my home router, I configured an address mapping between port 80 and my Openstack host. Here&#8217;s the screen shot:</p><div id="attachment_4960" style="width: 614px" class="wp-caption alignnone"><a href="http://jackkozik.com/wp-content/uploads/2015/01/NetgearRouterPortForwarding012215.png"><img class="wp-image-4960 size-large" src="http://jackkozik.com/wp-content/uploads/2015/01/NetgearRouterPortForwarding012215-1024x103.png" alt="NetgearRouterPortForwarding012215" width="604" height="60" /></a><p class="wp-caption-text">Port Forwarding Table from my home router</p></div><p>Now verify that http://my.external.IP.address/dashboard works.</p><h3>Setup an Openstack Subdomain Name</h3><p>One of my domain names, jackkozik.net points to my home router&#8217;s IP address. I setup an Openstack subdomain name, using my zoneedit account &#8212; I used os.jackkozik.net. Sorry no screen shot. I am (perhaps too liberally) showing my domain name, but I am reluctant to show my IP addresses. Zoneedit is pretty quick, but distributing a new subdomain address takes anywhere from 0 to 60 minutes.</p><p>I then edit Openstack&#8217;s virtual server configuration adding os.jackkozik.net as a ServerAlias, as follows:</p><pre>$ cd /etc/httpd/conf.d
$ vi 15-horizon_vhost.conf
...
&lt;VirtualHost *:80&gt;
ServerName kozik4.lan
ServerAlias os.jackkozik.net # Add this line
...
ZZ
$ systemctl restart httpd.service</pre><p>Then assuming the subdomain has had a chance to get distributed, verify http://os.jackkozik.net/dashboard.</p><p>Openstack&#8217;s install scripts automatically setup this VirtualHost.</p><h3>Create Subdomains for Each of My Instances</h3><p>Within Openstack, I create instances that are automatically assigned IP addresses from a pool in the range of 192.168.100.100-119. Of course these instances are accessible from my home network (eg http://192.168.100.100 displays a nice Apache default screen). But I only have one external IP address and I need a mechanism to for external web access.</p><p>Absent any better approach (I hope to find one!), I am using Apache&#8217;s ProxyPass capability. I have used this for physical servers, why not use it for virtual machines?!</p><p>For starters, I created another subdomain in zoneedit. I decided to name each external instance with a letter followed by the least significant digits from the IP address. My first subdomain is named f100: That is, it is a Fedora instance and it&#8217;s running an instance mapped to 192.168.100.100. In zoneedit, I enter the subdomain f100.jackkozik.net, and I put the same external IP address that I used for os.jackkozik.net.</p><p>Within the Apache configuration files, I created a virtual server named f100.jackkozik.net, and used ProxyPass to map it to (redirect it to?) the web server running on 192.168.100.100. See the following config file:</p><pre>$ cd /etc/httpd/conf.d
$ vi openstackInstances_vhost.conf
# This file configures all the proxy modules:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
&lt;VirtualHost *:80&gt;
ServerName f100.jackkozik.net
ProxyPreserveHost On
ProxyPass / http://192.168.100.100/
ProxyPassReverse / http://192.168.100.100/
&lt;/VirtualHost&gt;
ZZ
$ systemctl restart httpd.service</pre><p>I created this file and put it in the conf.d directory. It automatically gets read whenever the apache web server starts.</p><p>From here, allowing enough time for zoneedit to work, I verified that http://f100.jackkozik.net worked from both my home network and from an outside network (I sometime use my desktop PC at work test this; more commonly I use the Chrome browser on my Android phone).</p><p>I edit this file for each new instance I setup.</p><p>So each of my instances think they are sitting on the internet, but really the Openstack host Apache server and my home network router&#8217;s NAT function are fooling it.</p><h3>Fix ALLOWED_HOSTS</h3><p>Finally, once I got everything working, I fixed ALLOWED_HOSTS to permit any traffic from my home subnet and only allow requests from URL os.jackkozik.net from the Internet. See following:</p><pre>$ cd /etc/openstack-dashboard
$ vi local_settings
...
ALLOWED_HOSTS = ['localhost', 'os.jackkozik.net', 'kozik4.lan', ]
#ALLOWED_HOSTS = ['*']
ZZ
$ systemctl restart httpd.service</pre><p>The post <a rel="nofollow" href="http://jackkozik.com/setting-virtual-servers-openstack-environment/">Setting up Virtual Servers in Openstack environment</a> appeared first on <a rel="nofollow" href="http://jackkozik.com">JackKozik.com</a>.</p> ]]></content:encoded> <wfw:commentRss>http://jackkozik.com/setting-virtual-servers-openstack-environment/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>