Archive

Archive for June, 2009

Nginx – failed (13: Permission denied) while reading upstream

June 24th, 2009 derek Comments off

NginxAt my job we are moving to Nginx for the load balancing of our sites. Nginx is a very powerful load balancing/proxy server tool. It allows weighting, ssl acceleration, among other functionality while remaining light weight and easy to configure.

In preperation for a large web services launch, I began to analyze some logs and keep an eye on the system. I noticed one of the sites that we’ve already deployed was hammering our error messages in /var/log/nginx/error.log reading:

2009/06/23 12:38:22 [crit] 808#0: *724154 open() “/var/nginx/tmp/proxy_temp/4/83/0000002834″ failed (13: Permission denied) while reading upstream, client: XXX.XXX.XXX.XXX, server: xxx.host.com, request: “GET /dir/page.php”, upstream: “http://backendserverip/dir/page.php”, host: “host.com”, referrer: “http://referrer.com/apage.php”

Upon reviewing the site I noticed some (not all) of the pages were only partially loading. The issue is exactly what the log says. Permission denied = Permission issue.

Check your /etc/nginx/nginx.conf (OpenBSD) file for the user nginx processes will run as:

user  nobody;

Or, do:

# ps aux | grep “nginx: worker process” | awk ‘{print $1}’
nobody

In both cases you see that I’m running the nginx worker process as user nobody. Now we need to check our permissions on: /var/nginx/tmp/proxy_temp

# ls -l /var/nginx/tmp/ | grep proxy_temp
drwxrwx—  12 nobody  _nginx  512 Jun 23 13:10 proxy_temp

Looks good. The directory is owned by nobody and is writeable by both nobody and the group _nginx. What could the issue be? Lets move up a level and check the permissions.

# ls -l /var/nginx | grep tmp
drwx——  5 _nginx  _nginx  512 May  7 11:54 tmp

Ah ha! The parent directory is owned my _nginx:_nginx and is only writeable for that user. Our user ‘nobody’ therefore does not have the permissions to write in here. So, we can do a few things. Either make the entire directory writeable by everyone or change the ownership.

# chmod 777 /var/nginx/tmp

or

# chown nobody:_nginx /var/nginx/tmp

This should cure your permissions issues and all pages should load completely (at least mine do!)

Simple Interface Bonding (Gentoo)

June 22nd, 2009 derek Comments off

GentooIts often necessary to add bonding (NIC teaming – in windows world) to a linux config. This gives you 2 things: higher throughput on the interfaces and redundancy (if a card or switch happens to die). I made this post just as a quick reference for how to do such on a Gentoo system.

This article assumes that you have the proper kernel configuration to support bonded interfaces.

Device Driver => Network device support => <M> Bonding driver support

Load the necessary modules for bonding and install the necessary packages.

linux# modprobe bonding
linux# echo “bonding” >> /etc/modules.autoload.d/kernel-2.6
linux# emerge net-misc/ifenslave

Configure the interfaces: vi /etc/conf.d/net

config_eth0=( “null” )
config_eth1=( “null” )
slaves_bond0=”eth0 eth1″
config_bond0=( “10.10.10.69/24″ )
routes_bond0=( “default gw 10.10.10.1″ )

Start the interface and setup to start on boot.

linux# ln -s /etc/init.d/net.lo /etc/init.d/net.bond0
linux# rc-update add net.bond0 default
linux# /etc/init.d/net.bond0 start

If you have eth0 and/or eth1 setup to start on boot already you will need to delete those init scripts.
linux# rc-update del net.eth0; rc-update del net.eth1

Test

Use MacFUSE and Macfusion SSH Mount

June 7th, 2009 derek No comments

AppleConstantly needing to edit files on remote systems? Find it tasking and annoying to edit localy and upload via ftp or ssh? Want to use your favorite editor to edit the files on the remote system rather than relying on the remote ‘vi’ or ‘nano’? MacFUSE and Macfusion can be a very powerful tool that can remedy all of the above. Below is a quick tutorial on how to setup and use it.

Download and install: MacFUSE and Macfusion

Enable Macfusion to run at startup and enable the menu item for quick mounting and remote file system access. Run Macfusion –> Preferences –> General –> ‘When I login, start’ –> ‘the macfusion agent’ and ‘the macfusion menu item’.

After reboot you will see a new Icon in your Menu Bar. If you select it, it will look something like…

Here you can see your various options and current mounted file systems. To setup a connection to a server, ‘Macfusion Menu Item’ –> ‘Open Configuration …’ –> ‘+’ –> Select connection type: SSHFS/FTPFS.

Configure the Connection Name, Hostname, User Name, Password.

Whalla! You should be all setup and able to edit and browse the files as if it was a local file system. Works great with your favorite editor (in this case TextMate).

TextMate tweak to prevent remote meta data files that can slowly make a mess out of the file system. Copy and paste the below line in the command line.

defaults write com.macromates.textmate OakDocumentDisableFSMetaData 1

TextMate Manual on Saving Files. TextMate Manual

To view hidden files via finder add the following line on the command line.

defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder

Original Source: http://minimaldesign.net/articles/read/remote-textmate-projects

Project: OpenBSD Network Appliance (Hardware Build)

June 4th, 2009 derek No comments

OpenBSDPart one of the OpenBSD Network Appliance is done. I’ve got all the hardware put together, everything is posting. RAM was seen. My biggest worry. A buddy of mine at work gave me 4 DIMMS of PC133 512MB. I was a little worried it wasn’t going to work. I thought the mo-bo used only PC100. Good news for me though! 2GB of RAM for this bad boy will be plenty!

Hardware Specs:

ASUS P3V4X Motherboard
Pentium Celeron 533MHz
2GB PC133 RAM (4 x 512MB)
6 NICs (3 x 100Mb 3COM – 3 x 100Mb Intel)
2 x 30GB Hard drives (RAID 1 intended)

Check out the gallery! Projects Home Page

Password Access (Mac)

June 4th, 2009 derek No comments

A good friend of mine (Huggz) discovered a way of pulling your root password on your Mac. The oveall concept is that you are dumping the human readable text out of /dev/vm/sleepimage into another file in which you will find some interesting stuff including your root password. Kinda scary!

This takes a good while to dump all the content as that file can be upwards to 2GB. Search through the /var/vm/sleepimage-ascii file and you will see some goodies.

mac:~ me$ sudo su -
mac:~ root# cd /var/vm
mac:vm root# strings -n 4 sleepimage > sleepimage-ascii

I found my password all through this file. While most of these will be your password just on a line, and depending on your password, would be hard to know it was a password. However, one line I ran across blatenly says passwordXXXXusernameXXXX (line: 4186701 – for me). If you search throuh more you will see other lines that clearly displays hostname, username, password, home directory (lines: 7810286-7810293 – for me). If you keep digging you can find not only the login information for this particular machine but others for Samba mounts, ftp, web sites, etc. Good stuff!!!

There is also a more complete and detailed write up of other file dumps over at theInterW3bs.

Categories: Mac, Security Tags: , , , ,

Carp Interfaces on VMWare (OpenBSD)

June 1st, 2009 derek No comments

OpenBSDHere at work we’ve setup a testing environment of our production systems. That is, we’re using this environment to setup a perfect world that we will migrate production into…eventually.

We’re using OpenBSD for our firewalls and I was having a heck of a time getting the carp interfaces to work. The failover worked fine between the 2 VM load balancer/firewalls but the IPs on the carp interfaces were unreachable. This is apparently because VMs don’t support arbitrary MAC addresses and carp doesn’t support manually setting the MAC address. Long story short, the interfaces that are using carp, enable that network in ‘Promiscuous Mode’ in the VM management. Works like a charm now!

[Host Name] –> Configuration Tab –> Networking –> Properties –> [Network Name] –> Edit… –> Security

Original Source

Categories: Unix Tags: