Search code examples
pythonhttpuwsgi

Create a default vhost to serve http request in uwsgi


I've uwsgi 2.0.19 on Linux running with the python plugin. I serve http(s) traffic with different applications each for a specific record of my managed domain using such kind of configuration to register them to the front uwsgi servers.

subscribe2 = server=x.x.x.x:4443,key=domain.com,sni_key=/etc/ssl/private/domain.com.key,sni_cert=/etc/ssl/certs/domain.com.crt
subscribe2 = server=x.x.x.x:4443,key=domain.com:443,sni_key=/etc/ssl/private/domain.com.key,sni_cert=/etc/ssl/certs/domain.com.crt
subscribe2 = server=y.y.y.y:4443,key=domain.com,sni_key=/etc/ssl/private/domain.com.key,sni_cert=/etc/ssl/certs/domain.com.crt
subscribe2 = server=y.y.y.y:4443,key=domain.com:443,sni_key=/etc/ssl/private/domain.com.key,sni_cert=/etc/ssl/certs/domain.com.crt 

Now when I reach one of the front servers to access a not-existing host, I received such error (the TCP connexion is closed I assume)

curl: (52) Empty reply from server

I would like to be able to have a default/catchall key for such case, that permits to return an HTTP status 404 as I would do in Apache using the _default_ vhost. is it possible.


Solution

  • In order to implement this, you need to define a fallback application using the http-subscription-fallback-key on the front uwsgi server

    http-subscription-fallback-key=default
    

    default is a standard application registered on the frontal uwsgi like any other application

    subscribe2 = server=x.x.x.x:4443,key=default
    subscribe2 = server=x.x.x.x:4443,key=default:80