Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

migrated from Sep 29 '11 at 3:42

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

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) 

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)
share|improve this answer
your first suggestion breaks nginx and nginx.conf test fails causing nginx not to start – unc0nnected Aug 27 '12 at 23:43

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.

share|improve this answer
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

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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