I am trying to use nginx as a simple load balancer for django per Jacob Kaplan-Moss' example: http://github.com/jacobian/django-deployment-workshop http://python.mirocommunity.org/video/1689/pycon-2010-django-deployment-w
If I stop nginx and have apache listen on port 80 everything works fine. If I have apache listening to nginx my urls break.
When nginx is running, http://184.106../admin/ works, but http://184.106../admin (missing ending slash) breaks. It redirects to the name of the web server http://web1/admin/
I know it is nginx causing the issue because the redirect works fine in apache and django dev server.
Here is the nginx.conf that is running:
# Nginx conf (/etc/nginx/nginx.conf).
#
# Basic setup
#
user www-data;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
#
# Event/worker setup.
#
worker_processes 4;
events {
worker_connections 100;
}
#
# HTTP configuration
#
http {
include /etc/nginx/mime.types;
# HTTP upstream for load balancers.
# Replace the IPs below with IPs (or names) of your upstream Apaches
upstream sitename {
server 10.X.X.X:8000;
server 10.X.X.X:8000;
}
# The actual HTTP sever.
server {
listen 80;
# Don't proxy static files like robots.txt and favicon.ico.
location ~ ^/(favicon.ico|robots.txt|sitemap.xml)$ {
alias /home/web/static/$1;
}
# Serve media directly out of Nginx for performance
location /media {
alias /home/media;
}
# Proxy everything else to the backend
location / {
proxy_pass http://sitename;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header X-Handled-By $upstream_addr;
}
}
}