Commit Diff


commit - 98c8f038acfbcb3f9366c9e22e5d75255187afeb
commit + bd726b55be4df8535a2b200a252193649566007a
blob - f45d772143cbadddfb0d996d7d75565eb6b1eeb4
blob + 845ff6f1201a426365a0a510d668b8ae8fcff240
--- ChangeLog
+++ ChangeLog
@@ -1,5 +1,7 @@
 2021-01-15  Omar Polo  <op@omarpolo.com>
 
+	* cgi.c (start_cgi): set SERVER_NAME to the vhost when executing CGI scripts
+
 	* parse.y (option): add ability to specify the tls versions with "protocols"
 
 	* gmid.c (handle_open_conn): ensure the port number of the request matches
blob - 899932f2b879f9a81c452bb98c35d7c42b44ebf6
blob + 30f554ccbd5631180837cf6d545c069f17529de9
--- cgi.c
+++ cgi.c
@@ -119,7 +119,10 @@ start_cgi(const char *spath, const char *relpath, cons
 		safe_setenv("GATEWAY_INTERFACE", "CGI/1.1");
 		safe_setenv("SERVER_SOFTWARE", "gmid");
 		safe_setenv("SERVER_PORT", portno);
-		/* setenv("SERVER_NAME", "", 1); */
+
+		if (!strcmp(c->host->domain, "*"))
+			safe_setenv("SERVER_NAME", c->host->domain)
+
 		safe_setenv("SCRIPT_NAME", spath);
 		safe_setenv("SCRIPT_EXECUTABLE", ex);
 		safe_setenv("REQUEST_URI", requri);