<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nithin Kumar on Medium]]></title>
        <description><![CDATA[Stories by Nithin Kumar on Medium]]></description>
        <link>https://medium.com/@nithinkumar_84692?source=rss-69de3f784ef------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*kIiZKHwf0RpFT5mS0LN7Jg.jpeg</url>
            <title>Stories by Nithin Kumar on Medium</title>
            <link>https://medium.com/@nithinkumar_84692?source=rss-69de3f784ef------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 04:22:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nithinkumar_84692/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Single Server Staging Infra to support multiple developers]]></title>
            <link>https://medium.com/@nithinkumar_84692/single-server-staging-infra-to-support-multiple-developers-3563fdc2cf77?source=rss-69de3f784ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/3563fdc2cf77</guid>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[apache]]></category>
            <category><![CDATA[infra]]></category>
            <category><![CDATA[staging]]></category>
            <dc:creator><![CDATA[Nithin Kumar]]></dc:creator>
            <pubDate>Wed, 15 Apr 2020 18:11:44 GMT</pubDate>
            <atom:updated>2020-04-16T16:36:53.904Z</atom:updated>
            <content:encoded><![CDATA[<p>Currently all tech companies maintain separate infrastructure for staging to test the features. Multiple developers working on multiple features need their own private staging resources for testing their features. This can be achieved in multiple ways</p><ul><li><em>Having individual Servers for each of the devs</em></li></ul><p>This is solution is workable. Devs can start their own instance for testing their own features. The downside of this solution is, this can lead to a significant increase in the infra cost. The Server will be underutilized at certain times. Devs have to follow a habit to stop the server whenever they are done with the testing, or we can write a script to stop the instances if we detect inactivity in the instances</p><ul><li><em>We can have a common Server which can be shared by the devs</em>.</li></ul><p>Devs have to wait for other devs to get a slot. This solution might work if we have a few devs and we have fewer features under development. But this has a very low cost of running.</p><p>The solution we are proposing here has the advantages from both 1 and 2. i.e this approach can support a lot of devs at the minimal cost of staging infra.</p><p><strong>Proxy server</strong></p><p>The idea here is to run a proxy server on port 80 and assign some other ports to the developers. Based on the host, proxy passes all requests to the corresponding dev folder of developers.</p><p>I will here explain how to achieve this using Apache.</p><p>Suppose there are 2 developers Joe and Alice. We will run a proxy server on port 80. We also will have a dev folder for Alice and Joe on the server.</p><p>Now lets create config files for proxy and developers</p><p>create file <strong><em>/etc/httpd/httpd-proxy.conf</em></strong><br>Copy the default content to this file from default /<strong><em>etc/httpd/httpd.conf</em></strong></p><p>Do the following changes</p><pre>Listen 80<br># Proxy to Joe’s Instance<br>&lt;VirtualHost *:80&gt;<br> DocumentRoot &lt;Path_to_Joes_dev_folder&gt;<br> ServerName staging-joe.domain.com<br> ProxyPreserveHost on<br> # Port 8081 is assigned to Joe<br> ProxyPass / <a href="http://localhost:8081/">http://localhost:8081/</a><br> ProxyPassReverse / <a href="http://localhost:8081/">http://localhost:8081/</a><br>&lt;/VirtualHost&gt;<br><br># Proxy to Alice&#39;s Instance<br>&lt;VirtualHost *:80&gt;<br> DocumentRoot &lt;Path_to_Alice_dev_folder&gt;<br> ServerName staging-alice.domain.com<br> ProxyPreserveHost on<br> # Port 8082 is assigned to Joe<br> ProxyPass / <a href="http://localhost:8081/">http://localhost:8082/</a><br> ProxyPassReverse / <a href="http://localhost:8081/">http://localhost:8082/</a><br>&lt;/VirtualHost&gt;</pre><p>Now that we are ready with the proxy server, we need to create a separate apache config for Joe and Alice.</p><p>Create two files under <strong>/etc/httpd/httpd-alice.conf </strong>and <strong>/etc/httpd/httpd-joe.conf</strong></p><p>Now in <strong>/etc/httpd/httpd-joe.conf </strong>add the following lines</p><p>Since Joe’s application is running on port 8081</p><pre>Listen 8081<br># Joe Virtual Host<br>&lt;VirtualHost *:8081&gt;<br>   ServerName staging-joe.domain.com<br>   DocumentRoot &lt;Path to Joes dev folder&gt;<br>   &lt;Directory &lt;Path to Joes dev folder&gt;&gt;<br>     AllowOverride all<br>     Options -MultiViews<br>     Require all granted<br>   &lt;/Directory&gt;<br>   RailsEnv staging<br>   Header always set Strict-Transport-Security “max-age=16070400”<br>&lt;/VirtualHost&gt;</pre><p>Similarly in <strong>/etc/httpd/httpd-alice.conf</strong> add the following lines</p><pre>Listen 8082<br># Alice Virtual Host<br>&lt;VirtualHost *:8082&gt;<br>  ServerName staging-alice.domain.com<br>  DocumentRoot &lt;Path to Alice dev folder&gt;<br>  &lt;Directory &lt;Path to Alice dev folder&gt;&gt;<br>    AllowOverride all<br>    Options -MultiViews<br>    Require all granted<br>  &lt;/Directory&gt;<br>  RailsEnv staging<br>  Header always set Strict-Transport-Security “max-age=16070400”<br>&lt;/VirtualHost&gt;</pre><p>Now that we have created a separate apache config file for each dev. We can set an alias to <strong>reload</strong> or <strong>restart</strong> the application in case of any code changes. These restarts should not affect other devs operations.</p><p>For that, we can write some bash functions. That is <strong><em>restart joe</em></strong> means it should restart Joe&#39;s application and <strong><em>restart alice</em></strong> means it should restart Alice’s application. To implement this let’s create a bash file.</p><p>create a <strong>restart.sh </strong>file under some directory. Add the following content to that file</p><pre>#!/bin/bash<br>cd “/etc/init.d”<br>if [ “$1” = “joe” ]<br>then<br> sudo httpd -f /etc/httpd/conf/httpd-joe.conf -k restart<br> echo -e “\033[1m\033[Joe’s Apache Instance restarted!!\033[0m”<br>elif [ “$1” = “alice” ]<br>then<br> sudo httpd -f /etc/httpd/conf/httpd-alice.conf -k restart<br> echo -e “\033[1m\033[Alice’s Apache Instance restarted!!\033[0m”<br>elif [ &quot;$1&quot; = &quot;proxy&quot; ]<br>then<br>    sudo httpd -f /etc/httpd/conf/httpd-proxy.conf  -k restart<br>    echo -e &quot;\033[1m\033[32mProxy  Apache Instance restarted!!\033[0m&quot;<br>else<br> echo -e “\033[1m\033[31mNo Apache Instance Found!!\033[0m”<br>fi</pre><p>This file can be extended when we have more developers. After creating the file give execution permission by executing the following command.</p><pre>sudo chmod +x &lt;path_to_restart.sh&gt;</pre><p>To call this bash file from the terminal we can write alias functions in <strong>~/.bashrc</strong> or <strong>~/.bash_profile</strong></p><p>Add the following line to your <strong>~/.bashrc</strong> or <strong>~/.bash_profile</strong></p><pre>function restart () { &lt;path_to_restart.sh&gt; $1; }</pre><p>Now your staging infra is ready to support multiple developers in a single instance.</p><p>Now you can use <strong><em>restart proxy</em></strong> to start the proxy server and use <strong><em>restart alice</em></strong> or <strong>restart joe</strong> to start the dev servers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3563fdc2cf77" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>