<?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>React &#8211; Other Things</title>
	<atom:link href="https://blog.adamzolo.com/category/react/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.adamzolo.com</link>
	<description>Blog about Things by Adam Zolotarev</description>
	<lastBuildDate>Wed, 06 Sep 2017 01:40:05 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>Deploying React to Linux Server with Git Push</title>
		<link>https://blog.adamzolo.com/deploy-react-to-linux-server-git-deploy/</link>
					<comments>https://blog.adamzolo.com/deploy-react-to-linux-server-git-deploy/#respond</comments>
		
		<dc:creator><![CDATA[Adam Zolo]]></dc:creator>
		<pubDate>Wed, 06 Sep 2017 01:37:39 +0000</pubDate>
				<category><![CDATA[git]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[React]]></category>
		<guid isPermaLink="false">http://blog.adamzolo.com/?p=663</guid>

					<description><![CDATA[Selected VPS: Linode, 1GB Ram, 20 GB SSD, 1 TB transfer OS: Ubuntu 17.04 Web Server: Ngnix If you’d like to try Linode, I would greatly appreciate using this referral link – Linode: SSD Cloud Hosting &#038; Linux Servers Start with regular updates Set up fail2ban and Firewall I&#8217;m installing fail2ban 0.10 since it supports&#8230;<p><a class="more-link" href="https://blog.adamzolo.com/deploy-react-to-linux-server-git-deploy/" title="Continue reading &#8216;Deploying React to Linux Server with Git Push&#8217;">Continue reading <span class="meta-nav">&#8594;</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>Selected VPS: Linode, 1GB Ram, 20 GB SSD, 1 TB transfer<br />
OS: Ubuntu 17.04<br />
Web Server: Ngnix<br />
If you’d like to try Linode, I would greatly appreciate using this referral link – <a href="https://www.linode.com/?r=1e7f26b4b71e72c400ad072b526b5b846cceae1e" target="_blank">Linode: SSD Cloud Hosting &#038; Linux Servers</a></p>
<p>Start with regular updates</p>
<pre class="brush: plain; title: ; notranslate">
apt-get update &amp;&amp; apt-get upgrade
</pre>
<h3>Set up fail2ban and Firewall</h3>
<p>I&#8217;m installing fail2ban 0.10 since it supports ipv6. At the time of this post, it is not available as a regular package.</p>
<pre class="brush: plain; title: ; notranslate">
wget https://github.com/fail2ban/fail2ban/archive/0.10.0.tar.gz
tar -xvzf 0.10.0.tar.gz
python3 setup.py install

#To enable fail2ban as an automatic service, copy the script for your distro from the files directory to /etc/init.d.

cp files/debian-initd /etc/init.d/fail2ban
update-rc.d fail2ban defaults
service fail2ban start

#Add local jail
awk '{ printf &quot;# &quot;; print; }' /etc/fail2ban/jail.conf | sudo tee /etc/fail2ban/jail.local
vim /etc/fail2ban/jail.local
</pre>
<p>uncomment sshd section and add<br />
enabled = true</p>
<pre class="brush: plain; title: ; notranslate">
sudo apt-get install sendmail iptables-persistent
sudo service fail2ban start
</pre>
<p><strong>Firewall </strong>( allow established connections, traffic generated by the server itself, traffic destined for our SSH and web server ports. We will drop all other traffic):</p>
<pre class="brush: plain; title: ; notranslate">
sudo service fail2ban stop
sudo iptables -A INPUT -i lo -j ACCEPT
sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
sudo iptables -A INPUT -p tcp -m multiport --dports 80,443 -j ACCEPT
sudo iptables -A INPUT -j DROP

# easy way to rate-limit ssh with ufw:
# technically, we could do all of the iptables stuff with ufw
ufw enable
ufw limit ssh
</pre>
<p><strong>If using IPv6:</strong></p>
<pre class="brush: plain; title: ; notranslate">
ip6tables -A INPUT -p tcp --dport 80 -j ACCEPT
ip6tables -A INPUT -p tcp --dport 443 -j ACCEPT
ip6tables -A INPUT -p tcp --dport 22 -j ACCEPT # (replace with your undisclosed port)
ip6tables -A INPUT -p icmpv6 -j ACCEPT
ip6tables -A INPUT -j REJECT
ip6tables -A FORWARD -j REJECT
</pre>
<p>View iptables rules:</p>
<pre class="brush: plain; title: ; notranslate">
sudo iptables -S
</pre>
<p>Save iptables rules:</p>
<pre class="brush: plain; title: ; notranslate">
sudo dpkg-reconfigure iptables-persistent
sudo service fail2ban start
</pre>
<h3>SSH</h3>
<pre class="brush: plain; title: ; notranslate">
vim /etc/ssh/sshd_config

#Add or uncomment (if using Ubuntu &lt; 17.04)
protocol 2

#Add allowed ciphers
Ciphers aes128-ctr,aes192-ctr,aes256-ctr
KexAlgorithms ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256
MACs hmac-sha2-256,hmac-sha2-512
</pre>
<p><strong>Restart and test ssh config:</strong></p>
<pre class="brush: plain; title: ; notranslate">
service sshd restart
#returns nothing if everything configured properly
sshd -t
</pre>
<h3>NGINX</h3>
<pre class="brush: plain; title: ; notranslate">
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:nginx/stable
sudo apt-get install nginx
service nginx status
</pre>
<p>Update /etc/nginx/sites-enabled/default</p>
<pre class="brush: plain; title: ; notranslate">
root /var/www/html/your_site;

location / {
# Some comments...
try_files $uri /index.html;   # ADD THIS
}

sudo service nginx restart

</pre>
<h3>Installing React Dependencies</h3>
<pre class="brush: plain; title: ; notranslate">
# install yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo &quot;deb https://dl.yarnpkg.com/debian/ stable main&quot; | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update &amp;&amp; sudo apt-get install yarn
 
#install node (apt-get repo has an older version of Node)
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y build-essential

</pre>
<h3>GIT Push Deploy</h3>
<p>Let&#8217;s set up git on the server</p>
<pre class="brush: plain; title: ; notranslate">
apt-get install git-core
mkdir repos &amp;&amp; cd repos
mkdir your_site.git
cd your_site.git
git init --bare
</pre>
<p><b>Set up a post-push hook</b><br />
cd /repos/your_app.git/hooks<br />
touch post-receive</p>
<pre class="brush: plain; title: ; notranslate">
#!/bin/bash -l

GIT_REPO=$HOME/repos/your_app.git
TMP_GIT_CLONE=$HOME/tmp/git/your_app
PUBLIC_WWW=/var/www/html

git clone $GIT_REPO $TMP_GIT_CLONE
cd $TMP_GIT_CLONE
yarn install
yarn build
rm -rf $PUBLIC_WWW/your_app_bup
mv $PUBLIC_WWW/your_app $PUBLIC_WWW/your_app_bup
cp -a build/. $PUBLIC_WWW/your_app
rm -Rf $TMP_GIT_CLONE
exit
</pre>
<p>Run on post-receiv:</p>
<pre class="brush: plain; title: ; notranslate">
chmod +x post-receive
</pre>
<p>On your local machine:</p>
<pre class="brush: plain; title: ; notranslate">
git remote add linode root@remote_server_address:repos/your_app.git
git push linode master
</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.adamzolo.com/deploy-react-to-linux-server-git-deploy/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
