Search code examples
apachewsgicherrypy

cherrypy/wsgi behind apache ssl


I wrote a cherrypy application and now I need SSL. I am working with apache/wsgi and have a working python file running and returning pages. Now I am trying to get POSTs to work.

This is my working script:

import sys
sys.stdout = sys.stderr

import atexit
import threading
import cherrypy

cherrypy.config.update({'environment': 'embedded'})

if cherrypy.engine.state == 0:
    cherrypy.engine.start(blocking=False)
    atexit.register(cherrypy.engine.stop)

class Root(object):
    def index(self):
        # restrict access by ip address
        clientIP = cherrypy.request.headers["Remote-Addr"]
        if clientIP not in self.allowedIPs:
            return "Access Denied"

        return cherrypy.url()

    index.exposed = True
    allowedIPs = ["127.0.0.1", "192.168.174.1"]

application = cherrypy.Application(Root(), None)

If i make modifications to catch the post:

class Root(object):
    def index(self, files):

I receive the following error:

    <h2>404 Not Found</h2>
    <p>Nothing matches the given URI</p>

My apache config,

WSGISocketPrefix run/wsgi
NameVirtualHost *:443
<VirtualHost *:443>
        DocumentRoot /var/www/ssl_html
        ServerName   192.168.174.130:443
        ServerAlias 192.168.174.130

        SSLEngine On
        SSLCertificateFile /etc/ssl/certs/devel.crt
        SSLCertificateKeyFile /etc/ssl/certs/devel.key
        <Location />
                SSLRequireSSL
        </Location>

        WSGIDaemonProcess 192.168.174.130 processes=2 threads=15 display-name=%{GROUP}
        WSGIProcessGroup 192.168.174.130

        WSGIScriptAlias / /var/www/wsgi-scripts/helloWorld.py

</VirtualHost>

any help would be greatly appreciated! :)


Solution

  • def index(self, files):
    

    should be

    def index(self, file):
    

    ughh!! alas, fixed!