5

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?

3 Answers 3

7

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)
1
  • your first suggestion breaks nginx and nginx.conf test fails causing nginx not to start Commented Aug 27, 2012 at 23:43
3

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.

1
  • 1
    Thanks for the answer, deployment and programming go hand in hand though. What good is a program if no one can run it? Commented Jan 23, 2009 at 22:02
0

A old question, but for reference you could look at my blog post Using Nginx as SSL Proxy for Name Based VirtualHosts in Apache

It basically forwarding to apache on port 80, and using mod_rpaf (reverse proxy add forward) in apache so it will see the request as HTTPS, which is needed for frameworks who buildup their url by using the server variables.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .