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?

link|improve this question

67% accept rate
feedback

migrated from stackoverflow.com Sep 29 '11 at 3:42

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 6 down vote accepted

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)
link|improve this answer
feedback

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.

link|improve this answer
1  
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 Jan 23 '09 at 22:02
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.