<?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>Analysis and Review &#187; web server</title>
	<atom:link href="http://analysisandreview.com/tag/web-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://analysisandreview.com</link>
	<description>Brain Dumps For All</description>
	<lastBuildDate>Thu, 26 Jan 2012 20:58:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Best freeBSD Firewall for a Web Server, PF Configuration and Testing</title>
		<link>http://analysisandreview.com/unix/best-freebsd-firewall-for-a-web-server-pf-configuration-and-testing/</link>
		<comments>http://analysisandreview.com/unix/best-freebsd-firewall-for-a-web-server-pf-configuration-and-testing/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 04:03:01 +0000</pubDate>
		<dc:creator>Kurt</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[best freebsd firewall]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[pf]]></category>
		<category><![CDATA[pf configuration]]></category>
		<category><![CDATA[web server]]></category>
		<category><![CDATA[webserver]]></category>

		<guid isPermaLink="false">http://analysisandreview.com/?p=687</guid>
		<description><![CDATA[You&#8217;ll see many articles discussing various firewalls for BSD. freeBSD comes with three firewalls but I&#8217;ll lay out what I believe is the best freebsd firewall for a web server, pf. I need firewall that will help negate DDoS attacks, spoofing and fingerprinting. Allows port 80 and 443 as well as ssh and is simple ]]></description>
			<content:encoded><![CDATA[<div id="attachment_688" class="wp-caption alignright" style="width: 266px"><a href="http://analysisandreview.com/wp-content/blogs.dir/5/files/uploads/2010/02/freebsd-firewall.png"><img class="size-full wp-image-688" src="http://analysisandreview.com/wp-content/blogs.dir/5/files/uploads/2010/02/freebsd-firewall.png" alt="freeBSD 8 firewall for web server" width="256" height="256" /></a><p class="wp-caption-text">freeBSD 8 firewall for web server</p></div>
<p>You&#8217;ll see many articles discussing various firewalls for BSD. freeBSD comes with three firewalls but I&#8217;ll lay out what I believe is the best freebsd firewall for a web server, pf.<span id="more-687"></span></p>
<p>I need firewall that will help negate DDoS attacks, spoofing and fingerprinting. Allows port 80 and 443 as well as ssh and is simple to test and configure.</p>
<p>Well PF handles all that and comes built into the freeBSD kernel so it&#8217;s pretty easy and quick to set up and test.</p>
<p>do a ifconfig to figure out what your interface is named</p>
<pre class="brush: bash; title: ; notranslate">#ifconfig
bigkill# ifconfig
 re0:  flags=8843 metric 0 IC&amp;gt;
        ether 00:2c:c1:f9:5s:d3
        inet 224.210.155.13 netmask 0xfffffff8 broadcast 224.210.155.253
        media: Ethernet autoselect (100baseTX )
        status: active
lo0: flags=8049 metric 0
        inet 127.0.0.1 netmask 0xff000000
</pre>
<p>As you can see here the interface name is  re0</p>
<p> so just replace re0 in the below configuration and apply it to /etc/pf.conf</p>
<pre class="brush: bash; title: ; notranslate"> ### macro name for external interface.
ext_if = &quot;re0&quot;

### all incoming traffic on external interface is normalized and fragmented
### packets are reassembled.
scrub in on $ext_if all fragment reassemble

### set a default deny everything policy.
block all

### exercise antispoofing on the external interface, but add the local
### loopback interface as an exception, to prevent services utilizing the
### local loop from being blocked accidentally.
set skip on lo0
antispoof for $ext_if inet

### block anything coming from sources that we have no back routes for.
block in from no-route to any

### block packets that fail a reverse path check. we look up the routing
### table, check to make sure that the outbound is the same as the source
### it came in on. if not, it is probably source address spoofed.
block in from urpf-failed to any

### drop broadcast requests quietly.
block in quick on $ext_if from any to 255.255.255.255

### block packets claiming to come from reserved internal address blocks, as
### they are obviously forged and cannot be contacted from the outside world.
block in log quick on $ext_if from { 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 255.255.255.255/32 } to any

### block probes that can possibly determine our operating system by disallowing
### certain combinations that are commonly used by nmap, queso and xprobe2, who
### are attempting to fingerprint the server.
### * F : FIN  - Finish; end of session
### * S : SYN  - Synchronize; indicates request to start session
### * R : RST  - Reset; drop a connection
### * P : PUSH - Push; packet is sent immediately
### * A : ACK  - Acknowledgement
### * U : URG  - Urgent
### * E : ECE  - Explicit Congestion Notification Echo
### * W : CWR  - Congestion Window Reduced
block in quick on $ext_if proto tcp flags FUP/WEUAPRSF
block in quick on $ext_if proto tcp flags WEUAPRSF/WEUAPRSF
block in quick on $ext_if proto tcp flags SRAFU/WEUAPRSF
block in quick on $ext_if proto tcp flags /WEUAPRSF
block in quick on $ext_if proto tcp flags SR/SR
block in quick on $ext_if proto tcp flags SF/SF

### keep state on any outbound tcp, udp or icmp traffic. modulate the isn of
### outgoing packets. (initial sequence number) broken operating systems
### sometimes don't randomize this number, making it guessable.
pass out on $ext_if proto { tcp, udp, icmp } from any to any modulate state

### normally, a client connects to the server and we handshake with them, then
### proceed to exchange data. by telling pf to handshake proxy between the client
### and our server, tcp syn flood attacts from ddos become uneffective because
### a spoofed client cannot complete a handshake.

### set a rule that allows inbound ssh traffic with synproxy handshaking. yes I changed the ssh port
pass in on $ext_if proto tcp from any to any port 1229 flags S/SA synproxy state
### set a rule that allows inbound www traffic with synproxy handshaking.
pass in on $ext_if proto tcp from any to any port 80 flags S/SA synproxy state
pass in on $ext_if proto tcp from any to any port 443 flags S/SA synproxy state
 </pre>
<p> If you want to allow any other port simple copy the last line and replace the port number.</p>
<p> Now issue a reboot command to restart the system in 5 minutes to test your pf configuration.</p>
<pre class="brush: bash; title: ; notranslate"> shutdown -r +5
 </pre>
<p> Okay not start PF and test it</p>
<pre class="brush: bash; title: ; notranslate"> /etc/rc.d/pf onestart
 </pre>
<p> Now &#8220;test&#8221; the current configuration to see what you got</p>
<pre class="brush: bash; title: ; notranslate"> pfctl -s all&quot; ### list all the current rules that are in effect and shows current connections
 </pre>
<p> If you&#8217;re happy with your PF firewall configuration for freebsd 8 you&#8217;ll need to apply it at boot time by adding the following to your /etc/rc.conf</p>
<pre class="brush: bash; title: ; notranslate"> pf_enable=&quot;YES&quot;
pf_rules=&quot;/etc/pf.conf&quot;
 </pre>
]]></content:encoded>
			<wfw:commentRss>http://analysisandreview.com/unix/best-freebsd-firewall-for-a-web-server-pf-configuration-and-testing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>FreeBSD 8 LAMP Install for WordPress</title>
		<link>http://analysisandreview.com/unix/freebsd-8-lamp-install-for-wordpress/</link>
		<comments>http://analysisandreview.com/unix/freebsd-8-lamp-install-for-wordpress/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 15:48:15 +0000</pubDate>
		<dc:creator>Kurt</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[BAMP]]></category>
		<category><![CDATA[configure]]></category>
		<category><![CDATA[FAMP]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[phpMyAdmin]]></category>
		<category><![CDATA[Rollback]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[web server]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://analysisandreview.com/?p=658</guid>
		<description><![CDATA[How to install FreeBSD 8 for WordPress. It&#8217;s a basic LAMP install but since we&#8217;re not using linux it should be called BAMP or maybe FAMP? Who cares.. here are the steps to install FreeBSD 8 with apache, mySQL, PHP then install wordpress. I&#8217;ll be using ports of course for this entire install. I&#8217;m assuming ]]></description>
			<content:encoded><![CDATA[<p><a href="http://analysisandreview.com/wp-content/blogs.dir/5/files/uploads/2010/02/beastie.png"><img class="alignright size-full wp-image-683" src="http://analysisandreview.com/wp-content/blogs.dir/5/files/uploads/2010/02/beastie.png" alt="" width="178" height="196" /></a>How to install FreeBSD 8 for WordPress. It&#8217;s a basic LAMP install but since we&#8217;re not using linux it should be called BAMP or maybe FAMP? Who cares.. here are the steps to install FreeBSD 8 with apache, mySQL, PHP then install wordpress.</p>
<p>I&#8217;ll be using ports of course for this entire install. I&#8217;m assuming that you have the proper hardware for this type installation.</p>
<p>Start with a minimal installation of freeBSD 8</p>
<p><span id="more-658"></span></p>
<p>Bypass the headache and host on vps or dedicated servers with <a rel="nofollow" href="http://www.dpbolvw.net/click-2907135-10751178" target="_blank">pre-installed LAMP here</a>.</p>
<p>Update the server ports &#8211; <a rel="nofollow" href="http://www.freebsd.org/doc/handbook/ports-using.html" target="_blank">freebsd guide on ports</a></p>
<p>First update your port tree</p>
<pre class="brush: bash; title: ; notranslate">portsnap fetch update *if this is the first time do a portsnap fetch extract</pre>
<p>List available update</p>
<pre class="brush: bash; title: ; notranslate">pkg_version -vIL=</pre>
<p>Once you have updated your Ports Collection, before attempting a port upgrade, you should check /usr/ports/UPDATING. This file describes various issues and additional steps users may encounter and need to perform when updating a port, including such things as file format changes, changes in locations of configuration files, or other such incompatibilities with previous versions.</p>
<p>Upgrade your ports with</p>
<pre class="brush: bash; title: ; notranslate">portupgrade -rR</pre>
<p>Okay now that your freeBSD server ports are updates lets do Binary updates <a rel="nofollow" href="http://www.freebsd.org/doc/en/books/handbook/updating-freebsdupdate.html" target="_blank">freebsd-update</a>.</p>
<pre class="brush: bash; title: ; notranslate">freebsd-update fetch</pre>
<pre class="brush: bash; title: ; notranslate">freebsd-update install</pre>
<p>Then reboot</p>
<pre class="brush: bash; title: ; notranslate">shutdown -r now</pre>
<p>Verify update took place</p>
<pre class="brush: bash; title: ; notranslate">uname -a</pre>
<p>Rollback if necessary</p>
<pre class="brush: bash; title: ; notranslate">freebsd-update rollback</pre>
<p><strong>Now lets install Apache, PHP, mysql and phpMyAdmin on your freeBSD 8 web server.</strong></p>
<p>First install the latest <strong>apache </strong>from ports.</p>
<pre class="brush: bash; title: ; notranslate">cd /usr/ports/www/apache22/
make config install clean
echo 'apache22_enable=&quot;YES&quot;' &lt;&lt; /etc/rc.conf
echo 'apache22ssl_enable=&quot;YES&quot;' &lt;&lt; /etc/rc.conf
echo 'accf_http_ready=&quot;YES&quot;' &lt;&lt; /etc/rc.conf &amp;amp;&amp;amp; kldload accf_http</pre>
<p>Now install <strong>PHP</strong></p>
<pre class="brush: bash; title: ; notranslate">cd /usr/ports/lang/php5
make config install clean
cd /usr/ports/lang/php5-extensions  ** enable &lt;strong&gt;mysql &lt;/strong&gt;extensions **
make config install clean</pre>
<p>Now modify your httpd.conf &#8211; Add the following entries to /usr/local/etc/apache22/httpd.conf directly after all the LoadModule lines</p>
<pre class="brush: bash; title: ; notranslate">AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps</pre>
<p>now locate IfModule mod_dir.c and add index.php</p>
<pre class="brush: bash; title: ; notranslate">DirectoryIndex index.php index.html index.htm</pre>
<p>Last but not least get a good php.ini file setup</p>
<pre class="brush: bash; title: ; notranslate">cp /usr/local/etc/php.ini-recommended /usr/local/etc/php.ini</pre>
<p>Restart apache and</p>
<pre class="brush: bash; title: ; notranslate">/usr/local/etc/rc.d/apache22 start</pre>
<p>Now its time for <strong>mySQL </strong>installation, configuration and setup</p>
<pre class="brush: bash; title: ; notranslate">cd /usr/ports/databases/mysql50-server
make install WITH_OPENSSL=yes
make distclean
echo 'mysql_enable=&quot;YES&quot;' &lt;&lt; /etc/rc.conf</pre>
<p>Start mysql server and change root password</p>
<pre class="brush: bash; title: ; notranslate">/usr/local/etc/rc.d/mysql-server start
mysqladmin -u root password sumcrazypaswrd
mysql -u root -p    *make sure you can log in*
rm /root/.history  *remove history so password isn't exposed*</pre>
<p>Create a configuration file for mysql in /etc/my.cnf</p>
<pre class="brush: bash; title: ; notranslate">[client]
port=29912
[mysqld]
port=29912
bind-address=127.0.0.1</pre>
<p>Now lets install configure and setup <strong>phpMyAdmin</strong></p>
<pre class="brush: bash; title: ; notranslate">cd /usr/ports/databases/phpmyadmin
make config install clean
cd /usr/local/www/phpMyAdmin &amp;amp;&amp;amp; cp config.sample.inc.php
config.inc.php
vi config.inc.php
$cfg['blowfish_secret'] = 'sdf934sdfgHijh98Y';</pre>
<p>open httpd.conf and Alias</p>
<pre class="brush: bash; title: ; notranslate">Alias /phpmyadmin /usr/local/www/phpMyAdmin</pre>
<p>Now allow who you want to access it</p>
<pre class="brush: bash; title: ; notranslate">        &lt;Directory &quot;/usr/local/www/phpmyadmin'&lt;
Order allow,deny
        Allow from all   *or allow from 222.114.123.0/12*
&lt;/Directory&lt;</pre>
<p>you&#8217;ll want https when you connect to phpmyadmin so lets enable https and make some httpd.conf changes</p>
<p><strong>Create your certificate</strong></p>
<p>In order to access phpmyadmin of ssl you need to get https going on apache. You can buy an SSL certificate generated by a trusted CA such as Thwate or Verisign, or you can generate one yourself using OpenSSL. I borrowed a ton of infor from <a href="http://www.freebsdmadeeasy.com/tutorials/freebsd/create-a-ca-with-openssl.php">freebsdmadeeasy.com</a></p>
<p>lets get the openssl.cnf file ready</p>
<pre class="brush: bash; title: ; notranslate">vi /etc/ssl/openssl.cnf
dir = /root/sslCA
default_days = 3650</pre>
<p>Now set up the directories</p>
<pre class="brush: bash; title: ; notranslate">cd ~root/
mkdir sslCA
chmod 700 sslCA
chmod 700 sslCA
mkdir certs private newcerts
echo 1000 &lt; serial
touch index.txt
cd ~root/sslCA
openssl req -new -x509 -days 3650 -extensions v3_ca -keyout private/cakey.pem -out cacert.pem -config /etc/ssl/openssl.cnf</pre>
<p>The CA should now be all set.. test with more;</p>
<pre class="brush: bash; title: ; notranslate">more ~root/sslCA/cacert.pem
more ~root/sslCA/private/cakey.pem</pre>
<p>Now lets generate an SSL certificate for apache</p>
<pre class="brush: bash; title: ; notranslate">cd ~root/sslCA
openssl req -new -nodes -out yourhostname-req.pem -keyout private/yourhostname-key.pem -config /etc/ssl/openssl.cnf
openssl ca -config /etc/ssl/openssl.cnf -out yourhostname-cert.pem -infiles yourhostname-req.pem</pre>
<p>Lets put everything where it needs to be.</p>
<pre class="brush: bash; title: ; notranslate">mkdir /etc/ssl/crt
mkdir /etc/ssl/key
cp ~root/sslCA/yourhostname-cert.pem /etc/ssl/crt
cp ~root/sslCA/private/yourhostname-key.pem /etc/ssl/key</pre>
<p>And finally add the SSL virtual host</p>
<p>Find the below line in your httpd.conf and take the comment hash out.</p>
<pre class="brush: bash; title: ; notranslate"># Secure (SSL/TLS) connections
Include etc/apache22/extra/httpd-ssl.conf</pre>
<p>Now modify your httpd-ssl.conf</p>
<pre class="brush: bash; title: ; notranslate">ServerName ssl.yourhostname.com
SSLCertificateFile /etc/ssl/crt/yourhostname-cert.pem
SSLCertificateKeyFile /etc/ssl/key/yourhostname-key.pem
DocumentRoot &quot;/etc/www/apache22/data&quot;      ** whatever your location is**
ErrorLog &quot;/var/log/httpd-error.log&quot;
TransferLog &quot;/var/log/httpd-access.log&quot;</pre>
<p>In /usr/local/etc/apache22/extra/httpd-default.conf, disable ServerSignature to prevent the server from showing more information than it has to. Make sure the server-status and the server-info sections in /usr/local/etc/apache22/extra/httpd-info.conf are commented out.</p>
<p>Finally restart apache</p>
<pre class="brush: bash; title: ; notranslate">/usr/local/etc/rc.d/apache22 restart</pre>
<p>Now install <strong>wordpress</strong></p>
<pre class="brush: bash; title: ; notranslate">cd /usr/ports/wordpress
make install clean</pre>
<p>do a locate wordpress and move file to web root</p>
<pre class="brush: bash; title: ; notranslate">locate wordpress
cp /usr/local/www/data/wordpress/* /usr/local/whatever web root is</pre>
<p>go into web root and copy wp-config-sample.php to wp-config.php</p>
<p>navigate to https://hostname/phpmyadmin and create wordpress db &#8211; add that name to wp-config.php</p>
]]></content:encoded>
			<wfw:commentRss>http://analysisandreview.com/unix/freebsd-8-lamp-install-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

