amuck-landowner

Lightweight tiny 1x1 pixel web server

drmike

100% Tier-1 Gogent
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).
 

drmike

100% Tier-1 Gogent
Looks like the ARM installation on Debian/Raspbian is busted:

Code:
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
 

drmike

100% Tier-1 Gogent
Tinker time in Santa's workshop.  This is TINY.

Code:
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).  
 
Last edited by a moderator:
  • Like
Reactions: scv

scv

Massive Nerd
Verified Provider
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.
 
Last edited by a moderator:

willie

Active Member
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

Premium Buffalo-based Hosting
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
what about this told you it was busted? I must be missing it...
 

drmike

100% Tier-1 Gogent
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

Active Member
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

Content Contributer
If you want you can use Ruby too:

  1. Install Ruby

    apt-get install ruby

  2. Install webrick
    Code:
    gem install webrick
  3. Create webserver configuration
    Code:
    nano ~/webserver.rb
    Code:
        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
  4. Start it
    Code:
    ruby ~/webserver.rb

Done.
 

wlanboy

Content Contributer
How do I get that Ruby magic to server up 1 specific file and nothing more?  Like idiot.png
Or using lighttpd + rewrite:

Code:
$HTTP["host"]=~ "127.0.0.1"  {
        url.rewrite = ("(?i)(/.*\.(jpe?g|png|gif))$" => "/idiot.png" )
}
 
Last edited by a moderator:

k0nsl

Bad Goy
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 :)

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.
 
Last edited by a moderator:
Top
amuck-landowner