Commits

Alexey Rakeev committed d40249b Draft

Rewritten proxy routing to make apache aliases work

  • Participants
  • Parent commits 9082c58

Comments (0)

Files changed (2)

 	# Allow max 4 clients per IP
 	limit_conn conz 24;
 
-	proxy_set_header Host			$host;
-	proxy_set_header X-Real-IP		$remote_addr;
-	proxy_set_header X-Forwarded-For	$proxy_add_x_forwarded_for;
+	error_page 418 = @backend;
 
 	location / {
 		PROXY
-		# Higher burst for onload AJAX
-		limit_req zone=reqz burst=16;
 	}
 	location ~ /\.ht {
 		deny all;
 		location ~* ^/phpmyadmin/(.*)$ {
 			alias	/var/www/html/phpMyAdmin/$1;
 		}
-		location ~* ^/(squirrelmail|roundcube|uebimiau|atmail)/ {
+		location ~* ^/(webmail|squirrelmail|roundcube|uebimiau|atmail)/ {
 			root	/var/www/html;
+			try_files $uri @backend;
 		}
 	}
 	# Allow PHP for standard applications
 	location ~* ^/(phpmyadmin|webmail|squirrelmail|roundcube|uebimiau|atmail) {
+		return 418;
+	}
+	location @backend {
 		proxy_pass http://ADDR:$port;
-		limit_req zone=reqz burst=4;
+		proxy_set_header Host			$host;
+		proxy_set_header X-Real-IP		$remote_addr;
+		proxy_set_header X-Forwarded-For	$proxy_add_x_forwarded_for;
+
+		limit_req zone=reqz burst=16;
 	}
 }
 
 	proxy=""
 	if [ $pro -gt 0 ]; then
-		proxy="proxy_pass http://$ip:\$port;"
+		proxy="return 418;"
 	fi
 
 	resconf=$NGCONFDIR/vhost/$user-$domain.conf
 
 	sed -e s/ADDR/$ip/g -e s/PORT_SSL/$INTPORT_SSL/g -e s/PORT/$INTPORT/g \
 		-e s/DOCROOT_SSL/"${docroot_ssl//\//\/}"/g -e s/DOCROOT/"${docroot//\//\/}"/g \
+		-e s/LISTEN/"$listen"/g -e s/PROXY/"${proxy}"/g -e s/SSL/"${sslconf//\//\/}"/g \
 		-e s/USER/$user/g -e s/DOMAIN/$domain/g -e s/DOMLOG/$domain/g -e s/ALIAS/"$alias"/g \
-		-e s/LISTEN/"$listen"/g -e s/PROXY/"${proxy//\//\/}"/g -e s/SSL/"${sslconf//\//\/}"/g \
 		$NGCONFDIR/domain.conf > $resconf
 
 	if [ -f $userdir/domains/$domain.subdomains ]; then