Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 set my server up my nginx server like this:

server {
   listen 443;
   ssl on;
   ssl_certificate /etc/ssl/certs/;
   ssl_certificate_key     /etc/ssl/private/;
   ... other things down here..

How can I exclude directories from SSL? For example, under /static/tour I have a tour explaining the web application and there is no need to encrypt that.

OS: Ubuntu 10.04

share|improve this question
up vote 2 down vote accepted

I think you'll either want to set up another server configuration to listen on port 80, directed into the same document root (and make sure the app is forcing either SSL or non-SSL depending on URL being accessed, so the user can't just delete the 'S' from HTTPS), or use something like this:

share|improve this answer

This won't be possible. An SSL request is encrypted which means the server can't even tell what the URI looks like until after it has decrypted the request. There is no way of telling the client that it should send requests for a certain subdirectory using a non-SSL protocol.

As Demelziraptor said, you can set up two vhosts, one with SSL on port 443 and one without SSL on port 80.

You could easily have rewrite rules set up so that any request for /static/tour on the SSL vhost will cause a redirect to the same page on the non-SSL vhost and vice versa on the non-SSL vhost to redirect back to the SSL vhost.

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.