views:

1054

answers:

2

I have Nginx listening to traffic on port 80 and proxying certain request to Apache over port 8080. I am going to set up Nginx to listen to port 443 for https traffic, but my question is how should the proxying be done now? Does the proxy to Apache need to be https or has Nginx already decoded it so I can keep sending it to Apache over port 8080. BTW, Apache is running with the least amount of modules installed possible and has currently has no SSL related modules, would I need to install any?

+1  A: 

That doesn't sound like a programming question, really... but anyway: no, you do not need SSL enabled on Apache. Only the server listening for HTTPS requests (on port 443) needs SSL.

David Zaslavsky
Thanks for the answer, deployment and programming go hand in hand though. What good is a program if no one can run it?
Jason Christa
+3  A: 

The following solution, as proposed by Graham Dumpleton, resolved the issue of SSL redirect loops while running nginx+ssl as a proxy to apache+wsgi.

In your nginx.conf file you need to have:

proxy_set_header X-Url-Scheme $scheme;

While your WSGI wrapper looks something like this:

import os, sys 

apache_configuration= os.path.dirname(__file__) 
project = os.path.dirname(apache_configuration) 
workspace = os.path.dirname(project) 
sys.path.append(workspace) 

os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings' 

import django.core.handlers.wsgi 

_application = django.core.handlers.wsgi.WSGIHandler() 

def application(environ, start_response): 
    environ['wsgi.url_scheme'] = environ.get('HTTP_X_URL_SCHEME', 'http') 
    return _application(environ, start_response)
Jason Christa