# Lightweight tiny 1x1 pixel web server



## drmike (Dec 3, 2013)

So I am finally getting my goofy setup for filtering, proxying, privacy, etc. in order.

Lots of blocked elements which I return 127.0.0.1 DNS value.

Instead of seeing random blocks of text, browser errors, etc.  Would like to serve up a 1x1 pixel instead.

So question for the collective brain trust, what does anyone else use for 1x1 pixel serving.   Lots of use on this one, bursts of load.  But, emphasis should be on something very lightweight and portable (i.e. will run on ARM as well as x86 Debian).


----------



## texteditor (Dec 3, 2013)

http://packages.debian.org/wheezy/httpd/micro-httpd

smallest httpd in debian, afaik


----------



## drmike (Dec 3, 2013)

Looks like the ARM installation on Debian/Raspbian is busted:


```
apt-get install micro-httpd
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  micro-proxy
The following NEW packages will be installed:
  micro-httpd
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/13.7 kB of archives.
After this operation, 60.4 kB of additional disk space will be used.
Selecting previously unselected package micro-httpd.
(Reading database ... 69198 files and directories currently installed.)
Unpacking micro-httpd (from .../micro-httpd_20051212-15_armhf.deb) ...
Processing triggers for man-db ...
Setting up micro-httpd (20051212-15) ...
grep: /etc/inetd.conf: No such file or directory
/var/lib/dpkg/info/micro-httpd.postinst: adding new /etc/inetd.conf entry
```


----------



## thekreek (Dec 3, 2013)

Sometime ago I used thttpd from the same creator of micro-httpd, it was fast and light on resources.


----------



## drmike (Dec 3, 2013)

Keep the recommendations coming


----------



## drmike (Dec 3, 2013)

Tinker time in Santa's workshop.  This is TINY.


```
1. Download or create 1x1 gif file.  Store it some place like /var/www   

2.  Create a new script:
nano /var/opt/serveit

while :; do nc -l 80 < /var/www/1x1.gif ; done

3. chmod +x /var/opt/serveit

4. sh /var/opt/serveit

Throw it up in crontab for running at reboot.

(mind you this is only good where you aren't utilizing port 80 for anything else or have very limited resources to work with).
```


----------



## scv (Dec 3, 2013)

I was gonna reply with an nc loop like that but looks like you beat me to it. Only real problem you'll have there is it's single threaded and lots of blocked content will cause the page to load really slowly. You might want to flesh it out a bit and build thttpd or something from source.

Also, I personally use NoScript. Lots of headache involved in configuring it right, but after a few months of using it you'll never get an alert from it when visiting your normal repertoire of bookmarks and when you do, you know something's up.


----------



## willie (Dec 3, 2013)

Old school:  http://cr.yp.to/publicfile.html

I've been thinking of using something like that to serve a bunch of static javascript like googleapis that I currently block with adblock, so sites I like can still use the code, without google receiving the queries.  I haven't bothered wiith the 1x1 pixel thing or nulling many addresses.  I just use adblock very aggressively and that seems to keep stuff out, though maybe I'm missing some. 

You may want to set up ssl in front of it too, maybe with pound.


----------



## texteditor (Dec 3, 2013)

drmike said:


> Looks like the ARM installation on Debian/Raspbian is busted:
> 
> 
> apt-get install micro-httpd
> ...


what about this told you it was busted? I must be missing it...


----------



## drmike (Dec 4, 2013)

This:



> grep: /etc/inetd.conf: No such file or directory
> /var/lib/dpkg/info/micro-httpd.postinst: adding new /etc/inetd.conf entry


No init.d entries either....  I suppose one can manually run it long wise or create what it failed to.... but I consider that a busted installation.


----------



## willie (Dec 4, 2013)

drmike said:


> No init.d entries either....  I suppose one can manually run it long wise or create what it failed to.... but I consider that a busted installation.


Did you check and see that it failed to create the inetd.conf?  The grep error may have been the install script checking to see if there was aleady an entry, and failing (in this case) a little bit ungracefully.  I've never used micro httpd though.  If it's for a modern desktop pc (as opposed to a ram-starved vps) there's not much trouble running a bigger httpd.


----------



## wlanboy (Dec 4, 2013)

If you want you can use Ruby too:


Install Ruby

apt-get install ruby


Install webrick

```
gem install webrick
```
 
Create webserver configuration

```
nano ~/webserver.rb
```


```
require 'webrick'
    server = WEBrick::HTTPServer.new :BindAddress => "127.0.0.1", :Port => 80, :ServerType => WEBrick::Daemon
    server.mount "/var/www", WEBrick::HTTPServlet::FileHandler, './'
    trap('INT') { server.stop }
    server.start
```
 
Start it

```
ruby ~/webserver.rb
```
 

Done.


----------



## dcdan (Dec 4, 2013)

How many requests per second you want to be able to serve?


----------



## drmike (Dec 4, 2013)

wlanboy said:


> If you want you can use Ruby too:


How do I get that Ruby magic to server up 1 specific file and nothing more?  Like idiot.png


----------



## drmike (Dec 4, 2013)

dcdan said:


> How many requests per second you want to be able to serve?


40-400....


----------



## dcdan (Dec 4, 2013)

drmike said:


> 40-400....


In this case I would definitely go with nginx, it will have no problem at all with that kind of load, and its resource usage in this scenario will be close to zero.


----------



## wlanboy (Dec 4, 2013)

drmike said:


> How do I get that Ruby magic to server up 1 specific file and nothing more?  Like idiot.png


Or using lighttpd + rewrite:


```
$HTTP["host"]=~ "127.0.0.1"  {
        url.rewrite = ("(?i)(/.*\.(jpe?g|png|gif))$" => "/idiot.png" )
}
```


----------



## thekreek (Dec 15, 2013)

Another alternative I been using for static files recently on a RaspberryPI it's monkey server ( http://www.monkey-project.com/ ).

Even on a LES box I have it has been running with minimal memory usage for static files.


----------



## k0nsl (Dec 16, 2013)

I was actually just about to recommend this excellent project. I've got it running too on one of my servers, for almost ninety days so far, without any issues. This is one project I'm following quite closely 



thekreek said:


> Another alternative I been using for static files recently on a RaspberryPI it's monkey server ( http://www.monkey-project.com/ ).
> 
> Even on a LES box I have it has been running with minimal memory usage for static files.


----------



## dannix (Dec 16, 2013)

Especially for this there is pixelserv. https://github.com/h0tw1r3/pixelserv or some less featured version http://gpl.back2roots.org/source/routertech/fw/source/nsp/src/RT-utils/pixelserv.c


----------

