One of my client runs a video streaming site on a windows server, he asked me to optimize his site for high load and availability,
He also wanted that no unauthorized user be able to leech his B/W by hotlinking his video files, Only thing came in mind was to use nginx as file server. In order to Compile nginx on Windows just follow this article carefully
Though there are nginx binaries already available but they don’t have the required modules compiled to achieve above requirements.
So i had to compile nginx from source,
How to compile nginx on Windows
In order to build nginx on the Microsoft windows platform you must first install these:
- Microsoft Visual C compiler. Microsoft Visual Studio®
- MSYS
- Perl (If you want nginx with SSL support) .I used Active Perl
- PECL I used version pcre-8.37
- zlib
- OpenSSL Library
After installing above prerequisites please make sure that paths to Perl, MSYS bin directories are added to PATH environment variable, To set Visual C environment run vcvarsall.bat or vcvars32.bat script from Visual C directory of your visual studio.
X:\Program Files (x86)\Microsoft Visual Studio X.X\VC\bin
Now we must download nginx source ,to do that you can download zip file from here or you can install Mercurial client and after that run
hg clone http://hg.nginx.org/nginx
Now open command prompt with admin privilege and run command
bash
cd into the downloaded nginx source folder then Create a build and lib directories, and unpack zlib, PCRE and OpenSSL libraries sources into lib directory
mkdir objs mkdir objs/lib cd objs/lib tar -xzf ../../pcre-x.x.tar.gz tar -xzf ../../zlib-x.x.x.tar.gz tar -xzf ../../openssl-x.x.x.tar.gz
and then
auto/configure --with-cc=cl --builddir=objs --prefix= \ --conf-path=conf/nginx.conf --pid-path=logs/nginx.pid \ --http-log-path=logs/access.log --error-log-path=logs/error.log \ --sbin-path=nginx.exe --http-client-body-temp-path=temp/client_body_temp \ --http-proxy-temp-path=temp/proxy_temp \ --http-fastcgi-temp-path=temp/fastcgi_temp \ --with-cc-opt=-DFD_SETSIZE=1024 \ --with-select_module --with-http_ssl_module --with-ipv6 --with-http_flv_module \ --with-http_mp4_module --with-http_stub_status_module \ --with-http_secure_link_module \ --ngx_http_hls_module \ --with-pcre=objs/lib/pcre2-10.20/pcre2-10.20 \ --with-zlib=objs/lib/zlib-1.2.8/zlib-1.2.8 \ --with-openssl=objs/lib/openssl-1.0.1s \
make sure to update correct folder path in above command for
--with-pcre=objs/lib/pcre2-10.20/pcre2-10.20 \ --with-zlib=objs/lib/zlib-1.2.8/zlib-1.2.8 \ --with-openssl=objs/lib/openssl-1.0.1s \
Next
nmake -f objs/Makefile
If Everything went well you will have compiled nginx.exe in you “objs” folder
In Next part I will tell you how to setup nginx stream url with authentication to disable hotlinking and expiry of links