nginx

General posts that involve nginx, these will include howtos, configuration information and experiments

nginx config for reverse proxying WordPress & WP Super Cache and keeping the load off Apache2

0
The point

The whole point of this is to get as much load off of Apache as possible to keep the server running nice and smoothly.

Configuration

The configuration below will mean that nginx will serve basically everything;

  • static files
  • uploaded files and
  • cached content
simply replace the VARIABLES below and everything should be good to go, if copy-pasting from below isn't working properly you can download a full copy from here.

server {

listen 80; server_name DOMAIN_HERE;access_log /var/log/nginx/access.DOMAIN_HERE.log;

gzip on; gzip_disable msie6; # disable gzip for IE6 gzip_static More >

nginx log real IP from Pound

2

Recently I started using Pound as a load balancer to a cluster of nginx servers and found my access logs were filled with the IP address of the load balancer. I did some digging and found the correct way to "fix" this.

First thing you need to do is make sure you remove X-Forwarded-For from Pound

ListenHTTP

... snip ...

... snip ...

HeadRemove "X-Forwarded-For"

End

Once this is done, reload Pound.

Next you need nginx compiled with realip module - http://wiki.nginx.org/NginxHttpRealIpModule

On Ubuntu/Debian servers this module comes by default, otherwise you may have to compile it in yourself More >

Logging Google Analytics cookies with nginx

0

I was recently tasked with adding Google tracking cookies to our nginx logging for a couple of sites. It was so it could be pushed through a log processor.

It turned out too be a little trickier than it would have been with Apache, but the process itself is still quite simple.

Open up the server definition you wish to add it to and add a custom log format like below:

log_format g-a '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent" More >

WordPress + nginx + Varnish + Apache 2

22

Lately I've been doing a lot of work with Varnish, this includes testing it within a load balanced environment, putting it behind nginx, putting it in front of Solr, the list goes on.

This blog post will hopefully give you an insight in to a simple way of combining nginx, Varnish and Apache to create a powerful WordPress environment that can really take a hammering.

I'm going to assume you already have Apache and nginx working together, if not I suggest you read my other articles on these subjects to learn how to combine them.

Installing Varnish

sudo apt-get install varnish

Configuring More >

New syslog.tv nginx wordpress site configuration explained

5
Configuration changes

I made some modifications to my nginx configuration this weekend to improve performance and clear up some bugs.

upstream backend { server 127.0.0.1:81 fail_timeout=120s; }

server { listen 80; server_name syslog.tv;

access_log /var/log/nginx/access.syslog.tv.log;

gzip on; gzip_disable msie6; gzip_static on; gzip_comp_level 9; gzip_proxied any; gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

location / { root /var/www/syslog.tv;

set $wordpress_logged_in ""; set $comment_author_email ""; set More >

Building nginx on Red Hat and Debian to RPM/DEB-style locations

0

The title of this post is a bit stupid, but I honestly couldn't think of any other way to write it...

When compiling nginx by hand, by default make install will push the binaries out to /usr/local/nginx and it doesn't come with a start/stop script, understandably because it doesn't know which OS it is going to be installed on etc etc.

Recently I was tasked with building nginx to an old Red Hat Enterprise Live 4 server with no yum installation, no nginx package in up2date and not being able to find an RPM that's link wasn't dead.

I've always felt that, being a Debian user, people think of me More >

Show IP in Apache logs from nginx reverse proxy

3

This is a very quick blog to show you how to show a users IP address in your Apache access logs when the site in question is being reverse proxied to Apache through nginx.

You need the rpaf module for Apache, on Debian and Ubuntu this is simple to install

apt-get update && apt-get install libapache2-mod-rpaf && a2enmod rpaf && apache2ctl graceful

This set of commands will do the following;

  1. Update apt package list
  2. Install libapache2-mod-rpaf
  3. Enable mod-rpaf
  4. Gracefully restart Apache (doesn't kill connections)

Once installed you simple need to be sure to pass the correct headers through, so More >

nginx – increase increase server_names_hash_bucket_size

0

Today I ran in to something I'd never seen before when configuring nginx.

I ran the nginx config test, as I usually do before I restart it.

nginx -t

But, the response I got was interesting

2010/03/18 21:16:09 [emerg] 12299#0: could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32

2010/03/18 21:16:09 [emerg] 12299#0: the configuration file /etc/nginx/nginx.conf test failed

I found that one of the domain names I was using was over 32 characters in length, nginx's default max length.

Thankfully the fix was simple.

http More >

More nginx proxy_cache optimizations and nginx load balancing

4

This is yet another follow up to post to several previous posts about using nginx as a reverse proxy with caching. It is actually a direct addition to my post from a week or so ago which outlined how to actually using nginx's proxy caching feature which can be read here -- http://syslog.tv/2010/02/07/nginx-proxy_cache-and-explained-benchmarked/.

Even more changes?

Yes, even more changes, these are basic changes that are there to improve the caching capabilities and also implement load balancing.

Cache changes

The first set of changes are in the main nginx configuration More >

nginx, proxy_cache and reverse proxying explained & benchmarked

3
The beginning

Where to begin? nginx would be a good start I suppose. It's far easier and makes much for sense for you to actually read about nginx from it's own website - http://nginx.org/en/ - but just to give a simple explanation too; `nginx is king of static content HTTP servers.`

Anyone that has dealt with Apache on medium to high traffic websites will know that Apache is bit of a `wheezy, old geezer` when it comes to content serving using it's mpm-worker (threaded). Very often high traffic will cause server load to go through the roof but for serving dynamic content, there really is no More >

Go to Top