Using http/https in a single server block ("ssl" parameter for "listen")

Igor Sysoev is at rambler-co.ru
Wed Apr 1 22:47:13 MSD 2009


On Wed, Apr 01, 2009 at 08:23:18PM +0200, Daniel Hahler wrote:

> Hi,
> 
> I'd like to enable both http and https within a single server block,
> without having to copy the whole block and only change "listen 80" to
> "listen 443" and add "ssl on".
> 
> This appears to work somehow using the "ssl" parameter with "listen",
> but "nginx -t" complains that it can be used together with "default"
> only (""ssl" parameter can be specified for the default "listen"
> directive only").
> However, obviously I can use "default" only once.
> 
> Would it be possible to allow usage of the "ssl" parameter without
> having to use "default"?
> 
> The example for "ssl" at
> http://wiki.nginx.org/NginxHttpCoreModule#listen uses "default", but
> it's not mentioned in the documentation that this is a requirement.
> 
> Example:
> server {
>     server_name example.com;
>     listen 80;
>     listen 443 ssl;
> 
>     location / {
>         proxy_pass http://server;
>     }
> }
> 
> I'm using nginx/0.7.47.

I can not say right now if is it possible to allow "ssl" parameter
on non-default listen, but how do you plan to use two name-based
SSL servers on one IP-address:

 server {
     server_name example.com;
     listen 80;
     listen 443 ssl;
 }

 server {
     server_name beispiel.de;
     listen 80;
     listen 443 ssl;
 }

?


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list