<div dir="ltr">Hey All,<br><br>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.<br><br>
Standard form posts work, no problem.<br><br>Uploading of files, however, fails. I see the back end /tmp folder being touched but no temp file being placed.<br><br>So here is my nginx.conf snippet on the front end:<br><br>
worker_processes 4;<br><br>error_log /var/log/error.log info;<br><br>pid /var/run/nginx.pid;<br><br><br>events {<br> worker_connections 1024;<br> use kqueue;<br>}<br><br><br>http {<br> include mime.types;<br>
default_type text/html;<br><br><br> sendfile on;<br> tcp_nopush on;<br> tcp_nodelay off;<br><br> #keepalive_timeout 0;<br> keepalive_timeout 5;<br><br> gzip on;<br>
gzip_http_version 1.0;<br> gzip_comp_level 2;<br> gzip_proxied any;<br> gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;<br>
<br> map_hash_max_size 2000000;<br> map $user $valid {<br> include /usr/local/etc/nginx/webusers.txt;<br> }<br><br><br> server {<br> listen 80;<br> server_name .<a href="http://domain.com">domain.com</a>;<br>
<br> # Strip leading www. and redirect<br> if ( $http_host ~ ^www\.([^\.]+)\.domain\.com ) {<br> set $user $1;<br> rewrite ^/(.*)$ http://$<a href="http://user.domain.com/$1">user.domain.com/$1</a> redirect;<br>
break;<br> }<br><br> # Get username from the hostname<br> set $user '-';<br> if ( $http_host ~ ^([^\.]+)\.domain\.com ) {<br> set $user $1;<br> }<br>
if ( $user = '-') {<br> return 404;<br> }<br><br> # Get the users port and ads<br> set $server $valid;<br> if ($server = 'invalid') {<br> rewrite ^ <a href="http://www.domain.com/invalid.php">http://www.domain.com/invalid.php</a> redirect;<br>
break;<br> }<br><br> if ($server = 'TERMINATED') {<br> rewrite ^ <a href="http://www.daomin.com/terminated.php">http://www.daomin.com/terminated.php</a> redirect;<br>
break;<br> }<br><br> if ($server = 'SUSPENDED') {<br> rewrite ^ <a href="http://www.domain.com/suspended.php">http://www.domain.com/suspended.php</a> redirect;<br>
break;<br> }<br><br> if ($server = 'RESERVED') {<br> rewrite ^ <a href="http://www.domain.com/reserved.php">http://www.domain.com/reserved.php</a> redirect;<br>
break;<br> }<br><br> log_format main '$http_host $remote_addr - $remote_user [$time_local] $request '<br> '"$status" $body_bytes_sent "$http_referer" '<br>
'"$http_user_agent" "$http_x_forwarded_for"';<br><br> access_log /var/log/access.log main;<br><br> location / {<br> proxy_set_header Host $host;<br>
proxy_set_header X-Real-IP $remote_addr;<br> proxy_set_header X-Forwarded-For $remote_addr;<br> proxy_redirect off;<br><br> # $server comes from the map<br>
proxy_pass http://$server$request_uri;<br><br> client_max_body_size 16m;<br> client_body_buffer_size 16k;<br><br> proxy_buffering off;<br><br> proxy_connect_timeout 5;<br>
proxy_send_timeout 90;<br> proxy_read_timeout 120;<br><br> error_page 502 503 504 <a href="http://www.domain.com/proxy_timeout.php">http://www.domain.com/proxy_timeout.php</a>;<br>
<br><br> proxy_pass_header Expires;<br> proxy_pass_header Cache-Control;<br> proxy_pass_header Last-Modified;<br> proxy_pass_header ETag;<br> proxy_pass_header Content-Length;<br>
<br> }<br><br> error_page 404 <a href="http://www.domain.com/404.php">http://www.domain.com/404.php</a>;<br> }<br><br>}<br><br><br>I have explicitly turned off proxy buffering - they are just passthrough servers mapping backends into a clean URL space.<br>
<br>Am I missing something obvious?<br><br>Tony<br></div>