<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
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/"
> <channel><title>Comments on: Top 20 Nginx WebServer Best Security Practices</title> <atom:link href="http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html/feed" rel="self" type="application/rss+xml" /><link>http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html</link> <description>This is a Linux sys admin journal by Vivek about sys admin work, Linux tips &#38; tricks, hacks, news and more.</description> <lastBuildDate>Fri, 10 Feb 2012 20:37:43 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: Arthur</title><link>http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html#comment-178912</link> <dc:creator>Arthur</dc:creator> <pubDate>Mon, 23 Jan 2012 15:19:10 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=6449#comment-178912</guid> <description>TIP:
I use NGinx as reverse proxy to several Apache  nodes.
And I had some &quot;Bad Gateway&quot; problems when using IPv6.
After try open a page using an IPv6 (AAAA) name,
nginx crashed with &quot;Bad Gateway&quot; message and Apache gives &quot;Segmentation Fault&quot;.
After dig a little bit, I discover that the problem were in the (lack of) IPv6 Linux Module.
A &quot;modprobe ipv6&quot; solved my problem.
=D</description> <content:encoded><![CDATA[<p>TIP:<br
/> I use NGinx as reverse proxy to several Apache  nodes.<br
/> And I had some &#8220;Bad Gateway&#8221; problems when using IPv6.</p><p>After try open a page using an IPv6 (AAAA) name,<br
/> nginx crashed with &#8220;Bad Gateway&#8221; message and Apache gives &#8220;Segmentation Fault&#8221;.</p><p>After dig a little bit, I discover that the problem were in the (lack of) IPv6 Linux Module.<br
/> A &#8220;modprobe ipv6&#8243; solved my problem.<br
/> =D</p> ]]></content:encoded> </item> <item><title>By: SuilAmhain</title><link>http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html#comment-176073</link> <dc:creator>SuilAmhain</dc:creator> <pubDate>Sat, 26 Nov 2011 02:35:11 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=6449#comment-176073</guid> <description>Hi,
Just a quick question on point  #7 Restrictive Iptables Based Firewall
I&#039;m trying to get an understanding of iptables and in doing so your output rules confuse me.
Plese see below example:
&lt;blockquote&gt;
$IPT -A INPUT -i ${PUB_IF} -s ${ip} -p tcp -d ${SERVER_IP} --destination-port 22 -j ACCEPT
$IPT -A OUTPUT -o ${PUB_IF} -d ${ip} -p tcp -s ${SERVER_IP} --sport 22 -j ACCEPT
&lt;/blockquote&gt;
I interpret that as being
Accept a SSH in to server from IP as defined in $PUB_SSH_ONLY.
Allow a ssh connection out to an IP as defined in $PUB_SSH_ONLY.
Why do you need the output rule?
Is it simply to allow a SSH connection to an IP defined in $PUB_SSH_ONLY or
is the output required as part of a handshaking process?
I know I should experiment and see but I&#039;m curious to the answer and that I may have a gap in my iptables understanding.
Thanks,
SuilAmhain</description> <content:encoded><![CDATA[<p>Hi,</p><p>Just a quick question on point  #7 Restrictive Iptables Based Firewall</p><p>I&#8217;m trying to get an understanding of iptables and in doing so your output rules confuse me.<br
/> Plese see below example:</p><blockquote><p> $IPT -A INPUT -i ${PUB_IF} -s ${ip} -p tcp -d ${SERVER_IP} &#8211;destination-port 22 -j ACCEPT<br
/> $IPT -A OUTPUT -o ${PUB_IF} -d ${ip} -p tcp -s ${SERVER_IP} &#8211;sport 22 -j ACCEPT</p></blockquote><p>I interpret that as being<br
/> Accept a SSH in to server from IP as defined in $PUB_SSH_ONLY.<br
/> Allow a ssh connection out to an IP as defined in $PUB_SSH_ONLY.</p><p>Why do you need the output rule?<br
/> Is it simply to allow a SSH connection to an IP defined in $PUB_SSH_ONLY or<br
/> is the output required as part of a handshaking process?</p><p>I know I should experiment and see but I&#8217;m curious to the answer and that I may have a gap in my iptables understanding.</p><p>Thanks,<br
/> SuilAmhain</p> ]]></content:encoded> </item> <item><title>By: jake</title><link>http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html#comment-174962</link> <dc:creator>jake</dc:creator> <pubDate>Tue, 18 Oct 2011 12:26:02 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=6449#comment-174962</guid> <description>THANK YOU SOOOOOOOOOOOO MUCH.
My server has suffered from socket port exhaustion for 2 years now.
Ive tried every sysctl variable and a hundred configurations from various linux administrators, and only YOUR sysctl.conf file did the trick.
Im not sure why, ive used all these parameters before, but it finally fixed the problem on centos and now I can run a load test for hours and never suffer from port exhaustion.
YOU ARE THE MAN!</description> <content:encoded><![CDATA[<p>THANK YOU SOOOOOOOOOOOO MUCH.</p><p>My server has suffered from socket port exhaustion for 2 years now.<br
/> Ive tried every sysctl variable and a hundred configurations from various linux administrators, and only YOUR sysctl.conf file did the trick.<br
/> Im not sure why, ive used all these parameters before, but it finally fixed the problem on centos and now I can run a load test for hours and never suffer from port exhaustion.<br
/> YOU ARE THE MAN!</p> ]]></content:encoded> </item> <item><title>By: gunt</title><link>http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html#comment-174672</link> <dc:creator>gunt</dc:creator> <pubDate>Thu, 06 Oct 2011 14:47:41 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=6449#comment-174672</guid> <description>Hi,
Thank you for this post. It really help me a lot.
I need your help with the hotlinking part, could you please tell me exactly which file
do I need to edit to stop the bad guys using my images.
I&#039;ll appreciate your help &#039;cause I can&#039;t find anywhere this info!
thanks</description> <content:encoded><![CDATA[<p>Hi,<br
/> Thank you for this post. It really help me a lot.<br
/> I need your help with the hotlinking part, could you please tell me exactly which file<br
/> do I need to edit to stop the bad guys using my images.<br
/> I&#8217;ll appreciate your help &#8217;cause I can&#8217;t find anywhere this info!<br
/> thanks</p> ]]></content:encoded> </item> <item><title>By: Bangon Kali</title><link>http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html#comment-172143</link> <dc:creator>Bangon Kali</dc:creator> <pubDate>Sun, 26 Jun 2011 17:28:18 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=6449#comment-172143</guid> <description>Thank you very much! These are very helpful!</description> <content:encoded><![CDATA[<p>Thank you very much! These are very helpful!</p> ]]></content:encoded> </item> <item><title>By: v13</title><link>http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html#comment-161462</link> <dc:creator>v13</dc:creator> <pubDate>Tue, 23 Nov 2010 08:47:35 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=6449#comment-161462</guid> <description>nice nginx security practices</description> <content:encoded><![CDATA[<p>nice nginx security practices</p> ]]></content:encoded> </item> <item><title>By: Ahmed</title><link>http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html#comment-160441</link> <dc:creator>Ahmed</dc:creator> <pubDate>Sun, 24 Oct 2010 14:52:46 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=6449#comment-160441</guid> <description>#12: How Do I Block Referral Spam?
Please remove that ! It can&#039;t make anything just getting CPU load average from 3 to 8 it makes nginx slower and it&#039;s not good for seo also.</description> <content:encoded><![CDATA[<p>#12: How Do I Block Referral Spam?<br
/> Please remove that ! It can&#8217;t make anything just getting CPU load average from 3 to 8 it makes nginx slower and it&#8217;s not good for seo also.</p> ]]></content:encoded> </item> <item><title>By: edogawaconan</title><link>http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html#comment-158764</link> <dc:creator>edogawaconan</dc:creator> <pubDate>Mon, 09 Aug 2010 09:15:54 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=6449#comment-158764</guid> <description>#10 should be done using server {} block.
&lt;code&gt;
server {
listen 80 default;
return 403;
}
&lt;/code&gt;
#11, I doubt nginx supports any other methods
And #12... I doubt there&#039;s any spambots left running using non-common user agent.
Additionally, running php-cgi and nginx daemons as different user is recommended. Setting owner of the files to root and making it non-group/world writable except for some directories used by php (in which should be set to php-owned and not group/world writable) is also recommended.</description> <content:encoded><![CDATA[<p>#10 should be done using server {} block.</p><p><code><br
/> server {<br
/> listen 80 default;<br
/> return 403;<br
/> }<br
/> </code></p><p>#11, I doubt nginx supports any other methods</p><p>And #12&#8230; I doubt there&#8217;s any spambots left running using non-common user agent.</p><p>Additionally, running php-cgi and nginx daemons as different user is recommended. Setting owner of the files to root and making it non-group/world writable except for some directories used by php (in which should be set to php-owned and not group/world writable) is also recommended.</p> ]]></content:encoded> </item> <item><title>By: edogawaconan</title><link>http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html#comment-158763</link> <dc:creator>edogawaconan</dc:creator> <pubDate>Mon, 09 Aug 2010 09:08:16 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=6449#comment-158763</guid> <description>There&#039;s no need to chroot both php-cgi and nginx in one place. Additionally, php-fpm has chroot functionality built-in.</description> <content:encoded><![CDATA[<p>There&#8217;s no need to chroot both php-cgi and nginx in one place. Additionally, php-fpm has chroot functionality built-in.</p> ]]></content:encoded> </item> <item><title>By: ruo91</title><link>http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html#comment-155350</link> <dc:creator>ruo91</dc:creator> <pubDate>Sun, 25 Apr 2010 14:41:17 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=6449#comment-155350</guid> <description>Very good!!</description> <content:encoded><![CDATA[<p>Very good!!</p> ]]></content:encoded> </item> <item><title>By: vinod</title><link>http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html#comment-155081</link> <dc:creator>vinod</dc:creator> <pubDate>Sat, 17 Apr 2010 05:59:50 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=6449#comment-155081</guid> <description>quite nice article.. but I have not understood yet why selinux is important :) ... I have been a FreeBSD guy and now started working on CentOS too...
I&#039;ve setup a video streaming server, using Nginx and php-fpm... ( this server transmits @ 3-4 mbps at average ) I am seeing a lot of erros like &quot;connection to upstream timed out &quot; etc , which throws a &quot; Bad Gateway&quot; at times. After a lot of googling I increased the time out of fcgi and that seem to alleviate the issue, but I am seeing such entries in the logs often. I assume the issue is with nginx getting failed to communicate with PHP engine...
I wonder if the error is common and do we have hotfix for the issue ? I doubt if that is an issue with any compiled module ?
Thanks!
Vinod !</description> <content:encoded><![CDATA[<p>quite nice article.. but I have not understood yet why selinux is important :) &#8230; I have been a FreeBSD guy and now started working on CentOS too&#8230;</p><p>I&#8217;ve setup a video streaming server, using Nginx and php-fpm&#8230; ( this server transmits @ 3-4 mbps at average ) I am seeing a lot of erros like &#8220;connection to upstream timed out &#8221; etc , which throws a &#8221; Bad Gateway&#8221; at times. After a lot of googling I increased the time out of fcgi and that seem to alleviate the issue, but I am seeing such entries in the logs often. I assume the issue is with nginx getting failed to communicate with PHP engine&#8230;</p><p>I wonder if the error is common and do we have hotfix for the issue ? I doubt if that is an issue with any compiled module ?</p><p>Thanks!<br
/> Vinod !</p> ]]></content:encoded> </item> <item><title>By: Alok Kumar</title><link>http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html#comment-155020</link> <dc:creator>Alok Kumar</dc:creator> <pubDate>Wed, 14 Apr 2010 13:11:59 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=6449#comment-155020</guid> <description>nice article, quite an informative</description> <content:encoded><![CDATA[<p>nice article, quite an informative</p> ]]></content:encoded> </item> <item><title>By: Vivek Gite</title><link>http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html#comment-154944</link> <dc:creator>Vivek Gite</dc:creator> <pubDate>Mon, 12 Apr 2010 08:23:45 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=6449#comment-154944</guid> <description>Yes, both Apache and Lighttpd are on my TODO lists. So stay tuned.</description> <content:encoded><![CDATA[<p>Yes, both Apache and Lighttpd are on my TODO lists. So stay tuned.</p> ]]></content:encoded> </item> <item><title>By: Vamsi Krishna</title><link>http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html#comment-154299</link> <dc:creator>Vamsi Krishna</dc:creator> <pubDate>Mon, 15 Mar 2010 15:29:44 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=6449#comment-154299</guid> <description>Thank you very much sir :)</description> <content:encoded><![CDATA[<p>Thank you very much sir :)</p> ]]></content:encoded> </item> <item><title>By: robert</title><link>http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html#comment-154295</link> <dc:creator>robert</dc:creator> <pubDate>Mon, 15 Mar 2010 14:25:40 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=6449#comment-154295</guid> <description>Hi,
It&#039;s great to see the complete step by step on hardening nginx web server.
Would you consider in writing something like that for lighttpd web server? :)</description> <content:encoded><![CDATA[<p>Hi,</p><p>It&#8217;s great to see the complete step by step on hardening nginx web server.</p><p>Would you consider in writing something like that for lighttpd web server? :)</p> ]]></content:encoded> </item> <item><title>By: Vivek Gite</title><link>http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html#comment-154173</link> <dc:creator>Vivek Gite</dc:creator> <pubDate>Mon, 08 Mar 2010 13:40:55 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=6449#comment-154173</guid> <description>@js&amp;c,
You can chroot nginx using chroot command under CentOS / RHEL or any Linux disro as follows. You need to copy /usr/local/nginx to your $D. Next copy /etc/{passwd,group,hosts,resolv.conf,php.ini} to $D/etc, You need to copy required libs to $D. Once done copy /lib64/* to $D too. Copy php-cgi to $D/usr/bin. Finally, copy required php modules such gd, php-mysql to $D/usr/lib64/php/modules directory. Run php-cgi in $D using  the following syntax
&lt;pre&gt;/usr/bin/spawn-fcgi -c $D -a 192.168.1.10 -p 9000 -P /var/run/php-cgi.fastcgi.pid -u nginx -g nginx -- /usr/bin/php-cgi&lt;/pre&gt;
Where,
D=/jail.dir
You need to place /dev/null and a few more entries in $D/dev. Do not add hard disk and/or any other block device entries in $D/dev. This is the main problem with chroot and it can be easily escaped if proper care is not taken, hence I recommend proper tools.
Update nginx.conf and point fastcgi to 192.168.1.10:9000. Once done start nginx as
&lt;pre&gt;chroot $D /usr/local/nginx/sbin/nginx&lt;/pre&gt;
HTH</description> <content:encoded><![CDATA[<p>@js&#038;c,</p><p>You can chroot nginx using chroot command under CentOS / RHEL or any Linux disro as follows. You need to copy /usr/local/nginx to your $D. Next copy /etc/{passwd,group,hosts,resolv.conf,php.ini} to $D/etc, You need to copy required libs to $D. Once done copy /lib64/* to $D too. Copy php-cgi to $D/usr/bin. Finally, copy required php modules such gd, php-mysql to $D/usr/lib64/php/modules directory. Run php-cgi in $D using  the following syntax</p><pre>/usr/bin/spawn-fcgi -c $D -a 192.168.1.10 -p 9000 -P /var/run/php-cgi.fastcgi.pid -u nginx -g nginx -- /usr/bin/php-cgi</pre><p>Where,<br
/> D=/jail.dir</p><p>You need to place /dev/null and a few more entries in $D/dev. Do not add hard disk and/or any other block device entries in $D/dev. This is the main problem with chroot and it can be easily escaped if proper care is not taken, hence I recommend proper tools.</p><p>Update nginx.conf and point fastcgi to 192.168.1.10:9000. Once done start nginx as</p><pre>chroot $D /usr/local/nginx/sbin/nginx</pre><p>HTH</p> ]]></content:encoded> </item> <item><title>By: js&#38;c</title><link>http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html#comment-154170</link> <dc:creator>js&#38;c</dc:creator> <pubDate>Mon, 08 Mar 2010 12:16:46 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=6449#comment-154170</guid> <description>@Amr,
Can you share your instructions on chrooting Nginx in a chroot jail?</description> <content:encoded><![CDATA[<p>@Amr,</p><p>Can you share your instructions on chrooting Nginx in a chroot jail?</p> ]]></content:encoded> </item> <item><title>By: Amr El-Sharnoby</title><link>http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html#comment-154155</link> <dc:creator>Amr El-Sharnoby</dc:creator> <pubDate>Sun, 07 Mar 2010 18:27:15 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=6449#comment-154155</guid> <description>Hello, Thanks a lot
I&#039;ve already implemented nginx on multiple servers to serve more than 200 TB of data monthly ..yes Terabyte not Gigabye, I know it.
Here is some comments I&#039;ve;
Re:#17: Run Nginx In A Chroot Jail (Containers) If Possible;
You CAN, of course, use traditional chroot kind of setup with nginx. It&#039;s just a little bit tricky, I&#039;m already setting it up with php fastcgi server chroot&#039;ed too.  you can contact me if you need the steps.
Re:#18: Limits Connections Per IP At The Firewall Level;
You can use something like the following in nginx; - this is already what I use on heavily loaded servers with many visitors behind proxies -
limit_req_zone  $binary_remote_addr  zone=ratezone:20m   rate=16r/s;
limit_req   zone=ratezone  burst=160 nodelay;
I believe that nginx can do it better than iptables, specially under a DDoS attack, because the iptables recent module have a maximum memory limit of 8MB, as I can remeber it, and after that it&#039;s either completely fail or drop everything ... nginx will do always behave better.
Re: #20: Restrict Outgoing Nginx Connections;
I think that It&#039;s better to do that using selinux policy ... if you use seedit , you can add some line like this to the nginx_t.sp ..
allownet -protocol tcp -port 21,25,80,110,143,443 client;
Thanks a lot</description> <content:encoded><![CDATA[<p>Hello, Thanks a lot<br
/> I&#8217;ve already implemented nginx on multiple servers to serve more than 200 TB of data monthly ..yes Terabyte not Gigabye, I know it.<br
/> Here is some comments I&#8217;ve;<br
/> Re:#17: Run Nginx In A Chroot Jail (Containers) If Possible;<br
/> You CAN, of course, use traditional chroot kind of setup with nginx. It&#8217;s just a little bit tricky, I&#8217;m already setting it up with php fastcgi server chroot&#8217;ed too.  you can contact me if you need the steps.</p><p>Re:#18: Limits Connections Per IP At The Firewall Level;<br
/> You can use something like the following in nginx; &#8211; this is already what I use on heavily loaded servers with many visitors behind proxies -</p><p>limit_req_zone  $binary_remote_addr  zone=ratezone:20m   rate=16r/s;<br
/> limit_req   zone=ratezone  burst=160 nodelay;</p><p>I believe that nginx can do it better than iptables, specially under a DDoS attack, because the iptables recent module have a maximum memory limit of 8MB, as I can remeber it, and after that it&#8217;s either completely fail or drop everything &#8230; nginx will do always behave better.</p><p>Re: #20: Restrict Outgoing Nginx Connections;<br
/> I think that It&#8217;s better to do that using selinux policy &#8230; if you use seedit , you can add some line like this to the nginx_t.sp ..</p><p>allownet -protocol tcp -port 21,25,80,110,143,443 client;</p><p>Thanks a lot</p> ]]></content:encoded> </item> <item><title>By: Emin</title><link>http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html#comment-154154</link> <dc:creator>Emin</dc:creator> <pubDate>Sun, 07 Mar 2010 14:02:04 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=6449#comment-154154</guid> <description>Re: #10
I find it much more clean and convenient to simply create a default website with blank webpage (or return error if preferred) that will respond to all non-matched queries.</description> <content:encoded><![CDATA[<p>Re: #10</p><p>I find it much more clean and convenient to simply create a default website with blank webpage (or return error if preferred) that will respond to all non-matched queries.</p> ]]></content:encoded> </item> <item><title>By: Ayman Fekri</title><link>http://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html#comment-154147</link> <dc:creator>Ayman Fekri</dc:creator> <pubDate>Sun, 07 Mar 2010 06:09:07 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=6449#comment-154147</guid> <description>very Good post.
But :why u consider mail () as dangerous functions ?</description> <content:encoded><![CDATA[<p>very Good post.<br
/> But :why u consider mail () as dangerous functions ?</p> ]]></content:encoded> </item> </channel> </rss>
