Topic: Configure Nginx Web Proxy
Topic type:
Set up the Nginx web proxy in the context of the installation guide.
Originally written by Walter McGinnis, Kete Project Lead for Katipo Communications, Ltd.
Part of the Installation Guide
Important Note: This step assumes that you are logged in as the user who will be running your Kete. For demos and development this is likely your normal account, for production this is the "kete" account if you have followed the conventions laid forth in the last step.
Configure your Nginx web proxy
First, download the appropriate template for your Nginx configuration.
Using Nginx 0.6.x
If you are doing the simple installation, go to here and download the document. If you are doing the installation with Capistrano, go here and download that document.
Using Nginx 0.5.x
If you are doing the simple installation, go to here and download the document. If you are doing the installation with Capistrano, go here and download that document.
Configuration
Next, edit the template adjusting your_app, your_user_account, your_home_directory_path and upstream lines to match your mongrel cluster ports appropriately.
Then do this:
$ sudo cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.orig # back up the original nginx.conf incase things go wrong
$ sudo cp your_edited_nginx_conf_file /usr/local/nginx/conf/nginx.conf
Now start or restart nginx:
On Debian or other Linux distributions that use /etc/init.d (and you have set up /etc/init.d/nginx):
$ sudo /etc/init.d/nginx restart
On Mac OS X, you likely haven't started nginx yet. You can use this:
$ sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
On Mac OS X, if nginx is already running use this to stop nginx first:
$ ps auxw | grep nginx # choose the pid for the master process run by root from the result
$ sudo kill the_master_pid
I haven't found a launchd plist for nginx for starting up automatically at boot yet. Please let me know in discussion if you find one.
Next step:
Configure your Kete site
Walter McGinnis
said nginx start up error
If you have a long server name in your nginx.conf, you might come across an error like this:
Starting nginx daemon: nginx2008/03/17 18:05:24 [emerg] 19990#0: could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32
This is because you server name is longer than can be handled by the server_names_hash. If you bump up the server_names_hash_bucket_size setting explicitly in your nginx.conf file, it should fix the error. Put in something like this (the http { should already be there):
...
http { # needed for longer server_names # server_names_hash_bucket_size 128; server_names_hash_bucket_size 64;
...
Cheers,
Walter
Tags: Nginx, Installation, error, fix