Serving Static Folder with NGINX

At work we install Lubuntu workstations very often, we have a custom install script for performance tuning and many others details, the problem is we all don't have the latest script version in our thumb drives (sometimes we change it daily), as I'm already running nginx for my local web development I had the idea of serving a static folder with all our quick'n'dirty scripts to get always the latest and shiniest.

So here it is, I need to serve one folder by HTTP, I'll put several files I need to download from time to time from others workstations.

Solution:

mkdir /var/www/static
chmod a+rw /var/www/static -R

Create the static folder and give permissions for a normal user to copy there.

Then set up nginx to serve it and we're done: vim /etc/nginx/sites/static.conf

server {
    listen       8080;
      location / {
        root    /var/www/static/;
        access_log   on;
        autoindex  on;
      }
}

Now the folder is accessible by http://your_ip_address:8080, go nuts downloading anything there with wget.

As a bonus here is the way of using wget as if were curl:

wget -q -O - 192.168.1.123:8080/somescript | bash

-q is for quiet, -O is to redirect the output and the - is an alias to std-out, this way is a shortcut for downloading somescript and running it with bash.

Comments !

social