mod_proxy_uwsgi doesn't work with unix domain sockets

Bug #1501854 reported by Cd-MaN
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
uwsgi (Debian)
Fix Released
Unknown
uwsgi (Ubuntu)
Fix Released
Undecided
Unassigned
Xenial
Fix Released
Medium
Unassigned

Bug Description

= SRU =

== Impact ==

Using unix domain sockets for getting traffic from Apache to uwsgi is impossible. This is a regression from previous releases.

== Regression Potential ==

Patch is upstream, and that part of the codebase hasn't been touched since. Presumably that means it has been well tested by other uwsgi users.
It was also previously applied in the Debian/Ubuntu package. It was dropped by accident.

The patch only applies to the mod_proxy_uwsgi module, so no other bits of uwsgi should be affected (it does build *many* binaries and packages).

== Test Case ==

=== demo.conf ===
<VirtualHost *:80>
 ServerName localhost

 ProxyPass / unix:/run/demo.sock|uwsgi://demo/
</VirtualHost>

=== demo.ini ===
[uwsgi]
plugin = python3
socket = /run/demo.sock
umask = 0111
wsgi-file = demo.py

=== demo.py ===
def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    return [b"Hello World"]

=== Steps ===
1. apt install apache2 libapache2-mod-proxy-uwsgi uwsgi-plugin-python3
2. a2enmod proxy_uwsgi
3. rm /etc/apache2/sites-enabled/000-default.conf
4. cp demo.conf /etc/apache2/sites-enabled/
5. service apache2 restart
   lazy chroot option: (. /etc/apache2/envvars; apache2)
6. uwsgi --ini demo.ini
7. curl http://localhost/

Success: Hello World

Failure: A 502 Proxy Error, with this in the logs:
DNS lookup failure for: demo returned by /

= ORIGINAL REPROT =
If I specify "ProxyPass unix:/run/uwsgi/app/site/socket|uwsgi://" (this is inside of a location block, so need for the initial path) I will get "error parsing URL //: Invalid host/port" in the apache logs when I try to access that URL. If I try to change the final part (ie. "|uwsgi://" to "|uwsgi://localhost/"), it just tries to connect through TCP.

The problem is fixed (at least for me) by the patch from the mailing list: http://lists.unbit.it/pipermail/uwsgi/2015-September/008185.html (I also let Debian know about this, so perhaps the fix will come from upstream - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=752783#35).

There is also a workaround: use "vanilla" mod_proxy_http over unix domain sockets:

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

PS. Apparently, if you have multiple instances of uwsgi you want to connect to, you need to specify different names for them (ie. "http://uwsgi-uds-foo/", "http://uwsgi-uds-bar/", etc), having just different paths to the sockets will not work.

Revision history for this message
Cd-MaN (panther79) wrote :

Forgot to specifty:

The server is a stock Ubuntu 15.04 server with all the software installed from the official repos. Ie:
- apache2: 2.4.10-9ubuntu1.1
- apache2-mpm-event: 2.4.10-9ubuntu1.1
- libapache2-mod-proxy-uwsgi: 2.0.7-1ubuntu2
- uwsgi: 2.0.7-1ubuntu2
- uwsgi-plugin-php: 2.0.7-1ubuntu2

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in uwsgi (Ubuntu):
status: New → Confirmed
Revision history for this message
Douglas Fraser (douglas-fraser) wrote :

Also seeing this on Xenial development branch.

libapache2-mod-proxy-uwsgi: 2.0.12-4ubuntu2
apache2: 2.4.18-1ubuntu1

It appears the patch is in the master branch of uwsgi but hasn't made it into a release yet and Debian had it for 2.0.11.x packages [1] but it got dropped [2] when they moved to 2.0.12.

It would be fantastic if this could make it in before Xenial release.

[1] https://anonscm.debian.org/cgit/pkg-uwsgi/uwsgi.git/tree/debian/patches/020151002~6ce856c.patch?h=debian/2.0.11.2-5
[2] https://anonscm.debian.org/cgit/pkg-uwsgi/uwsgi.git/commit/?id=78863b96b93f1a182cdb914b3da8ffa97c19aa19

Revision history for this message
Ben Webb (bjwebb67-googlemail) wrote :

Looks like the patch was re-added in Debian's 2.0.12-6 version https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=752783#78 . I'm not sure what the procedure is for this to reach Ubuntu.

description: updated
Changed in uwsgi (Ubuntu):
status: Confirmed → Fix Released
Changed in uwsgi (Ubuntu Xenial):
importance: Undecided → Medium
status: New → In Progress
description: updated
description: updated
Revision history for this message
Stefano Rivera (stefanor) wrote :
Revision history for this message
Robie Basak (racb) wrote :

I don't see anything corresponding to the Regression Potential considerations required in https://wiki.ubuntu.com/StableReleaseUpdates#Procedure. Please complete this.

Changed in uwsgi (Debian):
status: Unknown → Fix Released
Revision history for this message
Stefano Rivera (stefanor) wrote :

Robie: Sorry, forgot. I haven't done one of these in a while :)

Added.

description: updated
Revision history for this message
Brian Murray (brian-murray) wrote : Please test proposed package

Hello Cd-MaN, or anyone else affected,

Accepted uwsgi into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/uwsgi/2.0.12-5ubuntu3.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-xenial to verification-done-xenial. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-xenial. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in uwsgi (Ubuntu Xenial):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-xenial
Revision history for this message
Stefano Rivera (stefanor) wrote :

LGTM

tags: added: verification-done verification-done-xenial
removed: verification-needed verification-needed-xenial
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package uwsgi - 2.0.12-5ubuntu3.1

---------------
uwsgi (2.0.12-5ubuntu3.1) xenial; urgency=medium

  * Re-add patch cherry-picked upstream to fix apache 2.4 integration
    with unix domain sockets (accidentally dropped in 2.0.12-1).
    LP: #1501854

 -- Stefano Rivera <email address hidden> Tue, 29 Aug 2017 13:02:59 -0700

Changed in uwsgi (Ubuntu Xenial):
status: Fix Committed → Fix Released
Revision history for this message
Chris Halse Rogers (raof) wrote : Update Released

The verification of the Stable Release Update for uwsgi has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.