<?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>Admon Home &#187; nginx</title>
	<atom:link href="http://www.admon.org/tag/nginx/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.admon.org</link>
	<description>Linux System Administration</description>
	<lastBuildDate>Sat, 19 May 2012 03:36:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Nginx 1.0.6 RPM package SPEC file</title>
		<link>http://www.admon.org/nginx-1-0-6-rpm-package-spec-file/</link>
		<comments>http://www.admon.org/nginx-1-0-6-rpm-package-spec-file/#comments</comments>
		<pubDate>Sun, 04 Sep 2011 13:07:39 +0000</pubDate>
		<dc:creator>joseph</dc:creator>
				<category><![CDATA[Applications]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[rpm]]></category>
		<category><![CDATA[spec file]]></category>

		<guid isPermaLink="false">http://www.admon.org/?p=942</guid>
		<description><![CDATA[Here&#8217;s is a SPEC file for building the latest Nginx-v1.0.6 on RHEL/CentOS platform. My Basic modifications are: Nginx would be installed in a dedicated directory named /opt/admon/nginx The Nginx serves as a basic web server. Only a limited amount of modules are enabled. You can update it by tweaking the compiling parameter. The generated package [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-thumbnail wp-image-755" title="nginx" src="http://www.admon.org/wp-content/uploads/2010/01/nginx-150x150.png" alt="" width="150" height="150" />Here&#8217;s is a SPEC file for building the latest Nginx-v1.0.6 on RHEL/CentOS platform. My Basic modifications are:</p>
<ul>
<ul>
<li>Nginx would be installed in a dedicated directory named <em>/opt/admon/nginx</em></li>
<li>The Nginx serves as a basic web server. Only a limited amount of modules are enabled. You can update it by tweaking the compiling parameter.</li>
</ul>
</ul>
<p><span id="more-942"></span></p>
<ul>
<li>The generated package is &#8220;nginx-1.0.6-1.admon.x86_64.rpm&#8221;, where is also an example for your self-crafted packages&#8217; version control.</li>
</ul>
<p>It&#8217;s tested OK on RHEL-5u7. If you got any issues, please leave a comment for us.</p>
<p><strong>Nginx SPEC file for building RPM package</strong></p>
<pre># cat nginx-stable.spec
%define nginx_user      nginx
%define nginx_group     admon
%define _prefix         /opt/admon/nginx
%define nginx_home      %{_prefix}/lib/nginx
%define nginx_home_tmp  %{nginx_home}/tmp
%define nginx_logdir    %{_localstatedir}/log/nginx
%define nginx_confdir   %{_prefix}/etc
%define nginx_datadir   %{_datadir}/nginx
%define real_name       nginx
%define dist		admon
%define _unpackaged_files_terminate_build 0

Name:           nginx
Version:        1.0.5
Release:	1.%{dist}
Summary:        Robust, small and high performance http and reverse proxy server
Group:          System Environment/Daemons   

# BSD License (two clause)
# http://www.freebsd.org/copyright/freebsd-license.html
License:        BSD
URL:            http://nginx.org/
BuildRoot:      %{_tmppath}/%{real_name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires:      pcre-devel,zlib-devel,perl(ExtUtils::Embed)
Requires:           pcre,zlib
Requires:           perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
# for /usr/sbin/useradd
Requires(pre):      shadow-utils
Requires(post):     chkconfig
# for /sbin/service
Requires(preun):    chkconfig, initscripts
Requires(postun):   initscripts

Source0:    http://sysoev.ru/nginx/nginx-%{version}.tar.gz
Source1:    %{real_name}.logrotate
Source2:    virtual.conf
#Source3:    %{real_name}.init ## Its init script does not contained in this post

%description
This package is built by Admon.Org
The latest version for this is 1.0.6, which can be downloaded from http://sysoev.ru/nginx/.

%prep
%setup -q -n %{real_name}-%{version}

%build
# nginx does not utilize a standard configure script.  It has its own
# and the standard configure options cause the nginx configure script
# to error out.  This is is also the reason for the DESTDIR environment
# variable.  The configure script(s) have been patched (Patch1 and
# Patch2) in order to support installing into a build environment.
export DESTDIR=%{buildroot}
./configure \
    --user=%{nginx_user} \
    --group=%{nginx_group} \
    --prefix=%{nginx_datadir} \
    --sbin-path=%{_sbindir}/%{real_name} \
    --conf-path=%{nginx_confdir}/%{real_name}.conf \
    --error-log-path=%{nginx_logdir}/error.log \
    --http-log-path=%{nginx_logdir}/access.log \
    --pid-path=%{_localstatedir}/run/%{real_name}.pid \
    --lock-path=%{_localstatedir}/lock/subsys/%{real_name} \
    --with-http_realip_module \
    --with-http_gzip_static_module \
    --with-http_stub_status_module \
    --with-cc-opt="%{optflags} $(pcre-config --cflags)"
make %{?_smp_mflags} 

%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot} INSTALLDIRS=vendor
find %{buildroot} -type f -name .packlist -exec rm -f {} \;
find %{buildroot} -type f -name perllocal.pod -exec rm -f {} \;
find %{buildroot} -type f -empty -exec rm -f {} \;
find %{buildroot} -type f -exec chmod 0644 {} \;
find %{buildroot} -type f -name '*.so' -exec chmod 0755 {} \;
chmod 0755 %{buildroot}%{_sbindir}/nginx
%{__install} -p -D -m 0755 %{SOURCE1} %{buildroot}%{_initrddir}/%{real_name}
%{__install} -p -D -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/%{real_name}
%{__install} -p -d -m 0755 %{buildroot}%{nginx_confdir}/conf.d
%{__install} -p -m 0644 %{SOURCE3} %{buildroot}%{nginx_confdir}/conf.d
%{__install} -p -d -m 0755 %{buildroot}%{nginx_home_tmp}
%{__install} -p -d -m 0755 %{buildroot}%{nginx_logdir}

%clean
rm -rf %{buildroot}

%pre
%{_sbindir}/useradd -c "Nginx user" -s /bin/false -r -d %{nginx_home} %{nginx_user} 2&gt;/dev/null || :

%post
/sbin/chkconfig --add %{real_name}

%preun
if [ $1 = 0 ]; then
    /sbin/service %{real_name} stop &gt;/dev/null 2&gt;&amp;1
    /sbin/chkconfig --del %{real_name}
fi

%postun
if [ $1 -ge 1 ]; then
    /sbin/service %{real_name} condrestart &gt; /dev/null 2&gt;&amp;1 || :
fi

%files
%defattr(-,root,root,-)
%{nginx_datadir}/
%{_sbindir}/%{real_name}
#%{_mandir}/man3/%{real_name}.3pm.gz
%{_initrddir}/%{real_name}
%dir %{nginx_confdir}
%dir %{nginx_confdir}/conf.d
%config(noreplace) %{nginx_confdir}/conf.d/*.conf
%config(noreplace) %{nginx_confdir}/win-utf
%config(noreplace) %{nginx_confdir}/%{real_name}.conf.default
%config(noreplace) %{nginx_confdir}/mime.types.default
%config(noreplace) %{nginx_confdir}/fastcgi_params
%config(noreplace) %{nginx_confdir}/fastcgi_params.default
%config(noreplace) %{nginx_confdir}/fastcgi.conf
%config(noreplace) %{nginx_confdir}/fastcgi.conf.default
%config(noreplace) %{nginx_confdir}/koi-win
%config(noreplace) %{nginx_confdir}/koi-utf
%config(noreplace) %{nginx_confdir}/%{real_name}.conf
%config(noreplace) %{nginx_confdir}/mime.types
%config(noreplace) %{_sysconfdir}/logrotate.d/%{real_name}
%attr(-,%{nginx_user},%{nginx_group}) %dir %{nginx_home}
%attr(-,%{nginx_user},%{nginx_group}) %dir %{nginx_home_tmp}
%attr(-,%{nginx_user},%{nginx_group}) %dir %{nginx_logdir}

%changelog
* Wed Jul 20 2011 Denis Frolov  - 1.0.5-1
- rebuild to 1.0.5

* Sat Jun 05 2011 Denis Frolov  - 1.0.4-1
- rebuild to 1.0.4

* Tue May 26 2011 Denis Frolov  - 1.0.3-1
- rebuild to 1.0.3

* Wed May 11 2011 Denis Frolov  - 1.0.2-1
- rebuild to 1.0.2

* Sun May 10 2011 Denis Frolov  - 1.0.1-1
- rebuild to 1.0.1

* Wed Dec 15 2010 Denis Frolov  - 0.8.54-1
- rebuild to 0.8.54

* Thu Nov 30 2010 Denis Frolov  - 0.8.53-1
- rebuild to 0.8.53

* Wed Jun 16 2010 Denis Frolov  - 0.7.67-1
- rebuild to 0.7.67 * Thu Jun 08 2010 Denis Frolov  - 0.7.66-1
- rebuild to 0.7.66
...</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.admon.org/nginx-1-0-6-rpm-package-spec-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nginx: UserAgent based transfer rate limit</title>
		<link>http://www.admon.org/nginx-useragent-based-transfer-rate-limit/</link>
		<comments>http://www.admon.org/nginx-useragent-based-transfer-rate-limit/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 03:58:54 +0000</pubDate>
		<dc:creator>joseph</dc:creator>
				<category><![CDATA[Applications]]></category>
		<category><![CDATA[System Tuning]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[transfer rate]]></category>
		<category><![CDATA[useragent]]></category>

		<guid isPermaLink="false">http://planet.admon.org/?p=548</guid>
		<description><![CDATA[In this post we&#8217;ll show an example on how to implement transfer rate limitation in Nginx. As this limitation is User agent based, it can be very meaningful for high transfer volume websites like download site,  a mirror site like mirror.centos.org, etc. The configuration itself is easy to understand: server { listen 80; server_name test.admon.org; [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://planet.admon.org/wp-content/uploads/2010/01/nginx.png"><img class="alignleft size-full wp-image-755" title="nginx" src="http://planet.admon.org/wp-content/uploads/2010/01/nginx.png" alt="" width="176" height="137" /></a>In this post we&#8217;ll show an example on how to implement transfer rate limitation in <a href="http://nginx.net/">Nginx</a>. As this limitation is User agent based, it can be very meaningful for high transfer volume websites like download site,  a mirror site like <a href="http://mirror.centos.org/">mirror.centos.org</a>, etc.<br />
<span id="more-548"></span><br />
The configuration itself is easy to understand:</p>
<pre>server {
        listen   80;
        server_name  test.admon.org;
        access_log  /var/log/nginx/mirror.access.log;
        location / {
                root   /data/mirrors;
                autoindex on;
                index  index.html index.htm;
                if ($http_user_agent ~ "MSIE") {
                        limit_rate 2k;
                }
                if ($http_user_agent ~ "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)") {
                        return 404;
                }
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
                root   /var/www/nginx-default;
        }
}</pre>
<p>From the above line, we can see that, If visitors&#8217; User-Agent strings contains <em>MSIE</em>, the transfer rate is limited to 2000 Bytes only, and the other agent Firefox is not allowed to download any file from this site.</p>
<p>Let&#8217;s go further with some tests:<br />
For Internet Explorer:</p>
<pre>$ wget --no-cache --user-agent="Something with MSIE; bla bla" http://test.admon.org/file.gz -O /dev/null
--14:07:59--  http://test.admon.org/file.gz
           =&gt; `/dev/null'
Resolving test.admon.org... 94.75.214.118
Connecting to test.admon.org|94.75.214.118|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8,051,367 (7.7M) [text/plain]

 0% [                                     ] 49,152         2.08K/s  ETA 1:02:38</pre>
<p>For Normal User:</p>
<pre>$ wget --no-cache http://test.admon.org/file.gz -O /dev/null
--14:08:28--  http://test.admon.org/file.gz
           =&gt; `/dev/null'
Resolving test.admon.org... 94.75.214.118
Connecting to test.admon.org|94.75.214.118|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8,051,367 (7.7M) [text/plain]

100%[====================================&gt;] 8,051,367      6.34M/s             

14:08:29 (6.33 MB/s) - `/dev/null' saved [8051367/8051367]</pre>
<p>For a Bad User:</p>
<pre>$ wget --no-cache --user-agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)" http://test.admon.org/file.gz -O /dev/null
--14:09:22--  http://test.admon.org/file.gz
           =&gt; `/dev/null'
Resolving test.admon.org... 94.75.214.118
Connecting to test.admon.org|94.75.214.118|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
11:35:01 ERROR 404: Not Found.</pre>
<p>So you can use it for some purposes, like:</p>
<ul>
<li> Implement limitations for your visitors to get rid of some bad activities.</li>
<li> Limit SE&#8217;s crawling rate. (You can <a href="http://www.google.com/support/webmasters/bin/answer.py?hl=en&amp;answer=48620">define crawl rate in some SEs like google</a>, but not all of the Search Engines support this feathure.</li>
</ul>
<p>Dont forget that this is just a simple way to limit the transfer rate, things in real world is that the User-Agent for a web client can be easiliy modified.<br />
The Chinese version for this post is <a href="http://li2z.cn/2009/12/30/nginx-user_agent-limit_rate/">available here</a>, and if you have any issues, welcome to <a href="http://forum.admon.org/webmasters/">our webmaster forums</a>, thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.admon.org/nginx-useragent-based-transfer-rate-limit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

