Upload Issues with Nginx Reverse Proxy
Tony Holmes
atholmes at gmail.com
Sat Sep 13 22:12:20 MSD 2008
Hey All,
I am using nginx (sweet server) as a reverse proxy in front of some user
content web servers. Nginx redirects them to the right server/port given
information extracted from a database.
Standard form posts work, no problem.
Uploading of files, however, fails. I see the back end /tmp folder being
touched but no temp file being placed.
So here is my nginx.conf snippet on the front end:
worker_processes 4;
error_log /var/log/error.log info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use kqueue;
}
http {
include mime.types;
default_type text/html;
sendfile on;
tcp_nopush on;
tcp_nodelay off;
#keepalive_timeout 0;
keepalive_timeout 5;
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/html text/css application/x-javascript
text/xml application/xml application/xml+rss text/javascript;
map_hash_max_size 2000000;
map $user $valid {
include /usr/local/etc/nginx/webusers.txt;
}
server {
listen 80;
server_name .domain.com;
# Strip leading www. and redirect
if ( $http_host ~ ^www\.([^\.]+)\.domain\.com ) {
set $user $1;
rewrite ^/(.*)$ http://$user.domain.com/$1
redirect;
break;
}
# Get username from the hostname
set $user '-';
if ( $http_host ~ ^([^\.]+)\.domain\.com ) {
set $user $1;
}
if ( $user = '-') {
return 404;
}
# Get the users port and ads
set $server $valid;
if ($server = 'invalid') {
rewrite ^ http://www.domain.com/invalid.php
redirect;
break;
}
if ($server = 'TERMINATED') {
rewrite ^ http://www.daomin.com/terminated.php
redirect;
break;
}
if ($server = 'SUSPENDED') {
rewrite ^ http://www.domain.com/suspended.php
redirect;
break;
}
if ($server = 'RESERVED') {
rewrite ^ http://www.domain.com/reserved.php
redirect;
break;
}
log_format main '$http_host $remote_addr - $remote_user
[$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/access.log main;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_redirect off;
# $server comes from the map
proxy_pass http://$server$request_uri;
client_max_body_size 16m;
client_body_buffer_size 16k;
proxy_buffering off;
proxy_connect_timeout 5;
proxy_send_timeout 90;
proxy_read_timeout 120;
error_page 502 503 504
http://www.domain.com/proxy_timeout.php;
proxy_pass_header Expires;
proxy_pass_header Cache-Control;
proxy_pass_header Last-Modified;
proxy_pass_header ETag;
proxy_pass_header Content-Length;
}
error_page 404 http://www.domain.com/404.php;
}
}
I have explicitly turned off proxy buffering - they are just passthrough
servers mapping backends into a clean URL space.
Am I missing something obvious?
Tony
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20080913/126e0842/attachment.html>
More information about the nginx
mailing list