Commits

Alexey Rakeev committed 7f7a9a6 Draft

Simplified set of proper apache envs using scheme in ServerName

Comments (0)

Files changed (4)

 
 server {
 	set $root	DOCROOT;
-	set $iport	PORT;
-	set $eport	80;
+	set $port	PORT;
 	if ($scheme = https) {
 		set $root	DOCROOT_SSL;
-		set $iport	PORT_SSL;
-		set $eport	443;
+		set $port	PORT_SSL;
 	}
 	set $host_raddr	$host$binary_remote_addr;
 	set $limit_rate	512k;
 	# Allow max 4 clients per IP
 	limit_conn conz 24;
 
-	proxy_set_header Host			$host:$eport;
+	proxy_set_header Host			$host;
 	proxy_set_header X-Real-IP		$remote_addr;
 	proxy_set_header X-Forwarded-For	$proxy_add_x_forwarded_for;
 
 	location / {
 		PROXY
-		proxy_redirect http://$host:$eport/ /;
-
-		# Burst request rate for possible onload AJAX/generated resources
+		# Higher burst for onload AJAX
 		limit_req zone=reqz burst=16;
 	}
 	location ~ /\.ht {
 	}
 	# Allow PHP for standard applications
 	location ~* ^/(phpmyadmin|webmail|squirrelmail|roundcube|uebimiau|atmail) {
-		proxy_pass http://ADDR:$iport;
-		proxy_redirect http://$host:$eport/ /;
-
+		proxy_pass http://ADDR:$port;
 		limit_req zone=reqz burst=4;
 	}
 }
 RealIP On
 RealIPProxy 127.0.0.1
 RealIPHeader X-Real-IP
-
-SetEnvIf Host :443$ HTTPS=on
-RequestHeader edit Host :(80|443)$ ""
 RemoteIPInternalProxy 127.0.0.1
 RemoteIPHeader X-Real-IP
-
-SetEnvIf Host :443$ HTTPS=on
-RequestHeader edit Host :(80|443)$ ""
 
 	proxy=""
 	if [ $pro -gt 0 ]; then
-		proxy="proxy_pass http://$ip:\$iport;"
+		proxy="proxy_pass http://$ip:\$port;"
 	fi
 
 	resconf=$NGCONFDIR/vhost/$user-$domain.conf
 		if [ ! -f custom/$tpl.conf ]; then
 			cp $tpl.conf custom/
 		fi
+		if [[ "$tpl" == *_secure* ]]; then
+			sed -i 's/ServerName\s\+\(https\?:\/\/\)\?/ServerName https:\/\//Ig' custom/$tpl.conf
+		fi
 		sed -i -e s/:$EXTPORT/:$INTPORT/g -e s/:$EXTPORT_SSL/:$INTPORT_SSL/g \
 			-e "/CustomLog/I $ln_off" -e "/SSLEngine/I $ln_off" custom/$tpl.conf
 	done