[uWSGI] Battling uwsgi apache integration

Alexandre Rossi alexandre.rossi at gmail.com
Wed Sep 23 15:07:46 CEST 2015


Hi,

With the below patch and the following line in apache, it seems to
work. I will follow up if I can confirm this and test it still works
with TCP.

ProxyPass "/foo"  "unix:/var/run/uwsgi/foo.socket|uwsgi://uwsgi-uds-foo/"

Note: I use uwsgi-uds-foo as hostname instead of localhost because if
you have multiple entrie like these in the same apache conf, apache
thinks it is the same backend even though the unix socket path is
different. So it is mandatory to use different hostnames if you have
multiple app sockets.

Thanks,

Alex

--- uwsgi-2.0.7/apache2/mod_proxy_uwsgi.c       2014-09-05
06:48:15.000000000 +0200
+++ uwsgi-2.0.7.new/apache2/mod_proxy_uwsgi.c   2015-09-23
14:51:16.317165714 +0200
@@ -67,20 +67,18 @@
     }
     url += sizeof(UWSGI_SCHEME); /* Keep slashes */

-    // is it a unix socket ?
-    if (strlen(url) == 2) {
-       *sport = 0;
-    }
-    else {
-        err = ap_proxy_canon_netloc(r->pool, &url, NULL, NULL, &host, &port);
-        if (err) {
-            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
-                      "error parsing URL %s: %s", url, err);
-            return HTTP_BAD_REQUEST;
-        }
-       apr_snprintf(sport, sizeof(sport), ":%u", port);
+    err = ap_proxy_canon_netloc(r->pool, &url, NULL, NULL, &host, &port);
+    if (err) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
+                    "error parsing URL %s: %s", url, err);
+        return HTTP_BAD_REQUEST;
     }

+    if (port != UWSGI_DEFAULT_PORT)
+        apr_snprintf(sport, sizeof(sport), ":%u", port);
+    else
+        sport[0] = '\0';
+
     if (ap_strchr(host, ':')) { /* if literal IPv6 address */
         host = apr_pstrcat(r->pool, "[", host, "]", NULL);
     }


More information about the uWSGI mailing list