views:

146

answers:

1

When configuring nginx with a site that has ssl, the examples I find online basically duplicate the location settings. Most examples only have the default root location so it's not that big of a deal, but when you have a few locations and rewrite rules in place duplicating this configuration gets messy to maintain.

I've considered proxying the ssl requests to localhost to get around this, but that's kind of ugly. I've also considered using file includes, but the location configs for this site should be in 1 file since they are related.

Any suggestions?

Edit: We're using nginx version 0.6.32.

A: 

There's a similar question on serverfault. Here's their answer:

server {
  listen 80;
  listen 443 default ssl;

  # other directives
}

The ssl parameter is included as of 0.7.14, which means we can't use it, but it's a good solution if you're on a newer version of nginx.

Jack Chu